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

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

问题描述

注意:我使用的是 VBA 和 Office 2007.(我会使用 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 或 MAPIPR_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天全站免登陆