You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MS Outlook对象模型中电子邮件头的位置在哪里?

在Outlook对象模型中获取邮件头的方法

Outlook对象模型(OOM)确实没有直接对应PR_TRANSPORT_MESSAGE_HEADERS_W的属性,不过可以通过以下两种可靠方式获取邮件头:

  • 使用PropertyAccessor读取MAPI属性:
    这是最直接的解决方案,通过PropertyAccessor对象直接访问目标MAPI属性的标签。PR_TRANSPORT_MESSAGE_HEADERS_W对应的属性标签为http://schemas.microsoft.com/mapi/proptag/0x007D001F,以下是VBA示例代码:

    Sub RetrieveMessageHeaders()
        Dim targetMail As Outlook.MailItem
        Dim propAccessor As Outlook.PropertyAccessor
        Dim headerContent As String
        
        Set targetMail = Application.ActiveExplorer.Selection(1)
        Set propAccessor = targetMail.PropertyAccessor
        
        ' 读取PR_TRANSPORT_MESSAGE_HEADERS_W属性内容
        headerContent = propAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F")
        
        Debug.Print headerContent
    End Sub
    
  • 通过邮件内容间接提取(可靠性较低):
    部分邮件会在HTMLBody或RTFBody中附带邮件头信息,但这种方式不通用——并非所有邮件都会保留该内容,且需要额外解析文本结构,仅适合特定场景。

使用PropertyAccessor时需确保目标邮件对象有效,且当前上下文具备访问该属性的权限。

内容的提问来源于stack exchange,提问作者NewSites

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 22:32:38