gpt4 book ai didi

c# - 我的 Outlook 加载项如何获取用户在我的自定义菜单中右键单击的附件对象?

转载 作者:行者123 更新时间:2023-11-30 18:36:50 25 4
gpt4 key购买 nike

我想在上下文菜单中右键单击它并单击自定义按钮时获取当前选定的嵌入式附件对象。

这些是我到目前为止完成的步骤:

  • 为 ContextMenuInlinePicture 功能区上下文菜单添加了自定义按钮

    <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);
    }
  • 运行加载项时,右键单击嵌入的图像/附件,我可以看到自定义上下文菜单项。

enter image description here

  • 单击该按钮后,运行上述方法,但我无法获得“AttachmentSelection”。相反,我得到“MailItemSelection”。

enter image description here

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

最佳答案

我已经通过 MSDN 订阅事件解决方案联系了 Microsoft,他们告诉我不能这样做。

附加 MS 响应:

Hello Martin, I am from the Messaging Developer Support team and have now taken ownership of this case. I apologise for the delay, but my team currently has a very high workload and this is affecting our response times. I’ve had a look at the question as described at How can my Outlook add-in get the Attachment object the user is right-clicking in my custom menu? , and the simple answer is that it is not possible to do what you want to using the Outlook Object Model. Your code is doing what is expected, as you are querying the Explorer object for its selected items – and you are having the MailItem returned. This is the selected item in the Explorer object. There are no events/properties exposed by the preview pane, so it is not possible to determine which object is selected there. It would be possible to find all the inline attachments of the currently selected item if that would be helpful, but the functionality you are after is not available. Please let me know if you would like any further information.

关于c# - 我的 Outlook 加载项如何获取用户在我的自定义菜单中右键单击的附件对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13384389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com