C# 我的Outlook加载项如何获取用户在自定义菜单中右键单击的附件对象?
右键单击上下文菜单中的嵌入附件对象并单击自定义按钮时,我希望获取当前选定的嵌入附件对象。 到目前为止,我已经完成了以下步骤:C# 我的Outlook加载项如何获取用户在自定义菜单中右键单击的附件对象?,c#,outlook,vsto,outlook-addin,ribbonx,C#,Outlook,Vsto,Outlook Addin,Ribbonx,右键单击上下文菜单中的嵌入附件对象并单击自定义按钮时,我希望获取当前选定的嵌入附件对象。 到目前为止,我已经完成了以下步骤: 为ContextMenuLinePicture功能区上下文菜单添加了自定义按钮 <customUI ...> <contextMenus> <contextMenu idMso="ContextMenuInlinePicture"> <button id="SendInlinePictureToH
- 为ContextMenuLinePicture功能区上下文菜单添加了自定义按钮
<customUI ...> <contextMenus> <contextMenu idMso="ContextMenuInlinePicture"> <button id="SendInlinePictureToHbbButton" label="Send to HBB" onAction="OnSendInlinePictureToHbbButtonClick" /> </contextMenu> </contextMenus> </customUI>
- 通过右键单击它,我正在调用函数OnSendInlinePictureToHbbButtonClick:
public void OnSendInlinePictureToHbbButtonClick(IRibbonControl control) { var msg = "OnSendMailToHbbButtonClick \n\n"; if (control.Context is Explorer) { msg = "Context=Explorer \n"; var explorer = control.Context as Explorer; if (explorer.AttachmentSelection.Count >= 1) { msg += "AttachmentSelection \n"; msg = explorer.AttachmentSelection .Cast<Attachment>() .Aggregate(msg, (current, attach) => current + attach.DisplayName + "\n"); } else { var selection = explorer.Selection; msg += "MailItemSelection \n"; if (selection.Count == 1) { var olItem = new OutlookItem(selection[1]); msg = msg + olItem.Subject + "\n" + olItem.LastModificationTime; } else { msg = msg + "Multiple Selection Count=" + selection.Count; } } } MessageBox.Show(msg); }
public void OnSendInlinePictureToHbbButtonClick(IRIBOnControl控件) { var msg=“OnSendMailToHbbButtonClick\n\n”; if(control.Context是资源管理器) { msg=“Context=Explorer\n”; var explorer=control.Context作为浏览器; 如果(explorer.AttachmentSelection.Count>=1) { msg+=“附件选择\n”; msg=explorer.AttachmentSelection .Cast() .Aggregate(msg,(当前,附加)=>current+attach.DisplayName+“\n”); } 其他的 { var selection=explorer.selection; msg+=“MailItemSelection\n”; 如果(selection.Count==1) { var olItem=新的展望项目(选择[1]); msg=msg+olItem.Subject+“\n”+olItem.LastModificationTime; } 其他的 { msg=msg+“多重选择计数=“+Selection.Count; } } } MessageBox.Show(msg); }
- 运行外接程序时,我可以在右键单击嵌入的图像/附件时看到自定义上下文菜单项
- 单击该按钮后,将运行上述方法,但我无法获得“AttachmentSelection”。取而代之的是“MailItemSelection”李>
- 如何获取附件对象用户右键单击,以便我可以使用它