使用EntryID,StoreID和/或PR_ENTRYID打开Outlook邮件项目 [英] Open Outlook mail Item using EntryID, StoreID, and / or PR_ENTRYID

查看:281
本文介绍了使用EntryID,StoreID和/或PR_ENTRYID打开Outlook邮件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我正在使用VBA和Office2007.(我将使用C#,但是项目参数不允许这样做)

NOTE: I'm using VBA and Office 2007. (I would use C#, but the project parameters don't allow this)

我试图在Outlook或API中找到一些方法,该方法将允许我通过从Access数据库提供Outlook EntryID或MAPI"PR_ENTRYID"属性来打开Outlook邮件项目.我找到了许多上述代码的参考,但我从未见过有人实际发布过解决方案.我尝试包含对mapi32.dll和OLMAPI32.dll的引用,但出现以下错误:无法向指定文件添加引用".我猜这是因为这些dll是用于.NET的.

I'm attempting to find some method in Outlook, or an API, that will allow me to open an Outlook mail item by providing either the Outlook EntryID or the MAPI "PR_ENTRYID" property from an Access Database. I have found many references to said code, but I have never seen anyone actually post a solution. I have attempted in include references to mapi32.dll and OLMAPI32.dll, but I get the following error: "Can't add a reference to the specified file." I'm guessing this is because those dll's are meant for .NET.

您能提供的任何帮助将不胜感激.

Any help you can give would be greatly appreciated.

推荐答案

使用Namespace.GetItemFromID.请注意,第二个参数(商店ID)是可选的.如果有关存储已被Outlook触摸过,则可以在当前会话中忽略它.如果不是,Outlook将引发未知条目ID"异常.如果指定了商店条目ID,Outlook将首先打开它,并且商店提供者将有机会在MAPI系统中注册其条目ID.

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

这篇关于使用EntryID,StoreID和/或PR_ENTRYID打开Outlook邮件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆