【发布时间】:2018-03-25 04:40:45
【问题描述】:
与这个问题类似, Open Specific MailItem in Outlook from C# ,在 C# VSTO 应用程序中,我尝试使用 GetFolderFromID 方法在新的 Outlook 窗口/检查器中打开电子邮件,并传递 EntryID 和 商店 ID。
完整代码如下:
Outlook.Application myApp = new Outlook.ApplicationClass();
Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
Outlook.MAPIFolder mySentBox = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
Outlook.MailItem myMail = ((Outlook.MailItem)mySentBox.Items[1]);
string guid = myMail.EntryID;
string folderStoreID = mySentBox.StoreID;
Outlook.MailItem getItem = (Outlook.MailItem)mapiNameSpace.GetItemFromID(guid, folderStoreID);
getItem.Display();
只有在 Outlook 中已选择电子邮件时,以下代码才会在新窗口中打开请求的电子邮件。
getItem.Display();
如果不选择,则返回以下错误。
System.Runtime.InteropServices.ComException: 'A dialog box is open. Close it and try again'.
我还尝试添加一个新的检查器并通过它激活/显示电子邮件对象,但没有成功。
亲切的问候
【问题讨论】: