我試圖對Outlook 2010中的選定附件執行操作。 我在VS2012中創建了Outlook VSTO項目。VSTO Outlook:獲取選定的附件
這是添加在附着帶的按鈕XML:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<contextualTabs>
<tabSet idMso="TabSetAttachments">
<tab idMso="TabAttachments">
<group label="MyGroup" id="MyAttachmentGroup">
<button id="AttachButton"
size="large"
label="Do something"
imageMso="HappyFace"
onAction="DoSomething" />
</group>
</tab>
</tabSet>
</contextualTabs>
</ribbon>
</customUI>
這是ThisAddIn.cs
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new ProcessAttachment(this);
}
代碼這在ProcessAttachment類:
[ComVisible(true)]
public class ProcessAttachment : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
private ThisAddIn plugin;
public ProcessAttachment(ThisAddIn plugin)
{
this.plugin = plugin;
}
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
}
public void DoSomething(Office.IRibbonControl control)
{
var explorer = plugin.Application.ActiveExplorer();
var selection = explorer.Selection;
if (selection.Count > 0)
{
object selectedItem = selection[1];
var mailItem = selectedItem as Outlook.MailItem;
//How to get selected attachment?
}
}
}
如何獲得所選附件?
var attachsel = window.AttachmentSelection();這一行發生錯誤 – SANDEEP 2013-05-16 07:32:36