簡體   English   中英

我的Outlook加載項如何獲取用戶在我的自定義菜單中右鍵單擊的Attachment對象?

[英]How can my Outlook add-in get the Attachment object the user is right-clicking in my custom menu?

我想在上下文菜單中右鍵單擊它並單擊自定義按鈕時,獲取當前選擇的嵌入式附件對象。

這些是我到目前為止所做的步驟:

  • 為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); } 
  • 運行加載項時,我可以在右鍵單擊嵌入的圖像/附件時看到自定義上下文菜單項。

在此輸入圖像描述

  • 單擊該按鈕后,上面的方法運行,但我無法獲得“AttachmentSelection”。 相反,我得到“MailItemSelection”。

在此輸入圖像描述

  • 我如何獲得附件對象用戶是右鍵單擊 ,所以我可以使用它?

我通過MSDN訂閱事件解決方案聯系了Microsoft,他們告訴我這不可能。

附加MS響應:

您好,Martin,我來自Messaging Developer Support團隊,現已取得此案的所有權。 我為延遲道歉,但我的團隊目前工作量很大,這影響了我們的響應時間。 我已經看過這個問題,如我的Outlook加載項如何獲取用戶在我的自定義菜單中右鍵單擊的Attachment對象? ,簡單的答案是,無法使用Outlook對象模型執行您想要的操作。 您的代碼正在執行預期的操作,因為您正在查詢Explorer對象的所選項目 - 並且您正在返回MailItem。 這是Explorer對象中的選定項。 預覽窗格沒有公開事件/屬性,因此無法確定在那里選擇了哪個對象。 如果有幫助,可以找到當前所選項目的所有內聯附件,但您所使用的功能不可用。 如果您想了解更多信息,請與我們聯系。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM