通过Mail.EntryID从C#在Outlook中打开特定的MailItem

时间:2018-03-23 06:31:57

标签: c# outlook vsto

与此问题类似, Open Specific MailItem in Outlook from C#,在C#VSTO应用程序中,我尝试使用 GetFolderFromID 方法在新的Outlook窗口/检查器中打开电子邮件,并传递 EntryID STOREID 即可。

以下完整代码:

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'.

我还尝试添加一个新的检查员&通过它激活/显示电子邮件对象但没有成功。

亲切的问候

1 个答案:

答案 0 :(得分:0)

错误仅表示对话框已打开。确保没有显示模态窗口并确保您调用if let img = UIImage.screenShot { if let data = UIImagePNGRepresentation(img) { //send this data over web or store it anywhere } } )以模式方式显示项目。

相关问题