使用 MAPI 读取具有 RMS 保护的电子邮件正文

Reading email body of email with RMS protection using MAPI

我有一个 C++ Oulook 插件,可以读取外发电子邮件(在 ItemSend 事件期间)并分析它们。发送邮件并添加RMS权限时,外发邮件的PR_BODY_W 属性包含(而非正文):

This message is protected with Microsoft Information Protection. You can 
open it using Microsoft Outlook, which is available for iOS, Android, 
Windows, and Mac OS. Get Outlook for your device here: 
https://aka.ms/protectedmessage.

Microsoft Information Protection allows you to ensure your emails can't be 
copied or forwarded without your permission. Learn more at https://microsoft.com/rms.

通过调用 MailItem.Body 属性,使用 Outlook 对象模型成功检索到实体。

但是,有没有办法使用 MAPI 而不是 OOM 来读取正文?

PR_BODY中的文字确实是真身。但是,当 Outlook 在邮件中找到 RMS 附件时,它会用它在该附件中找到的内容替换真实的正文。 OOM 会为您屏蔽此行为。使用 MAPI,您必须自己进行解码。

Outlook/Exchange 条消息中的 RMS 附件受 [MS-OXORMMS]: Rights-Managed Email Object Protocol. Specifically, you're interested in Opening a Rights-Managed Email Message.

约束

这里是大纲:

  1. 从消息中抓取PidNameRightsManagementLicense
  2. 找到包含 "rpmsg.message"
  3. 条消息 class 的附件
  4. 解压RFC 1950
  5. 后面的附件
  6. 按照协议文档继续从附件中解压数据。
  7. ...

知道所有这些都是由 OXORMMS 管理的,我们可以在 GitHub 上找到以下项目,这可能具有指导意义:https://github.com/damico/test-inflate-rms.