Open Outlook mail Item using EntryID, StoreID, and / or PR_ENTRYID

别来无恙 提交于 2019-11-30 19:28:45

Use Namespace.GetItemFromID. Note the second parameter (store id) is optional. You can omit it if the store in question was already touched by Outlook is in the current session. If not, Outlook will raise the "unknown entry id" exception. If the store entry id is specified, Outlook will open it first, and the store provider will have a chance to register its entry ids with the MAPI system.

set App = CreateObject("Outlook.Application")
set NS = App.GetNamespace("MAPI")
NS.Logon
set Msg = NS.GetItemFromID(EntryID)
MsgBox Msg.Subject

For C#:

var ns = OutlookApp.GetNamespace("MAPI");
var item = ns.GetItemFromID(entryId) as MailItem;

Where OutlookApp has Microsoft.Office.Interop.Outlook._Application type.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!