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”

  • 如何获取附件对象用户右键单击,以便我可以使用它

我已通过MSDN订阅事件解决方案与Microsoft联系,他们告诉我这无法实现

附加MS响应:

你好,Martin,我来自消息传递开发人员支持团队 现在已经掌握了这个案件的所有权。很抱歉耽搁了,但是 我的团队目前工作量很大,这影响了我们的工作 响应时间。我已经看过了上面所描述的问题 ,答案很简单,你不可能做你想做的事 要使用Outlook对象模型,请执行以下操作。您的代码正在执行 应为,因为您正在查询资源管理器对象以获取其所选资源 items–您正在返回邮件项。这是 资源管理器对象中的选定项。没有事件/属性 由预览窗格显示,因此无法确定 对象被选中。这将有可能找到所有的内联 当前所选项目的附件(如果有帮助), 但您所追求的功能不可用。请让我 知道您是否需要进一步的信息