Microsoft Graph:如何从电子邮件中获取别名?

Microsoft Graph: How to get the alias from an email message?

当我使用 Microsoft Graph 检索邮件的 toRecipientsinternetMessageHeaders 时,我无法找到邮件发送到的实际电子邮件别名。我如何获得别名?它总是返回 "parent" 帐户,从不返回别名帐户。

例如,这会将 alias1@company.com 显示为帐户 email1@company.com 的别名。

要求:

https://graph.microsoft.com/v1.0/users/email1@company.com?$select=proxyAddresses

回复:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(proxyAddresses)/$entity",
    "proxyAddresses": [
        "smtp:alias1@company.com",
        "X500:/o=Org1/ou=External (xxxxx)/cn=Recipients/cn=00000000000000000000",
        "x500:/o=ExchangeLabs/ou=Exchange Administrative Group (xxxxx)/cn=Recipients/cn=1111111111111111",
        "smtp:email1@company.mail.onmicrosoft.com",
        "X500:/o=Org1/ou=Exchange Administrative Group (xxxxx)/cn=Recipients/cn=yyyyyyyy",
        "smtp:email1@company.onmicrosoft.com",
        "SMTP:email1@company.com"
    ]
}

然后我给 alias1@company.com 发了一封电子邮件。检索 toRecipientsinternetMessageHeaders 时我没有看到别名,只有父帐户 email@company.com.

要求:

https://graph.microsoft.com/v1.0/me/messages/{messageId}?$select=toRecipients,internetMessageHeader

回复:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('...')/messages(toRecipients,internetMessageHeaders)/$entity",
    "@odata.etag": "W/\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"",
    "id": "{messageId}",
    "internetMessageHeaders": [
        {
            "name": "Received",
            "value": "...."
        },
        {
            "name": "Received",
            "value": "..."
        },
        {
            "name": "Received",
            "value": "..."
        },
        {
            "name": "Authentication-Results",
            "value": "company.com; dkim=none (message not signed) header.d=none;company.com; dmarc=none action=none header.from=company.com;"
        },
        {
         ...
        }
    ],
    "toRecipients": [
        {
            "emailAddress": {
                "name": "FirstName LastName",
                "address": "email1@company.com"
            }
        }
    ]
}

你不能。

Microsoft Exchange Server、Office 365 和 Outlook.com(以前称为 Hotmail)不保留(或至少公开)SMTP RCPT TO 值(即信封地址)——这与To:Cc:Bcc: headers(请注意 Bcc header 通常根本不会发送给收件人) .

这就是 e-mail 用户可以收到看起来不像是发给他们的电子邮件的方式(因为 e-mail 服务器使用 RCPT TO 值来路由电子邮件和忽略 To: header.

请注意,当 RCPT TO 值未出现在任何 To:Cc: 或 [=13= 中时,anti-spam 软件通常会标记电子邮件] headers 在 late-1990s/early-200s mass-mailed 垃圾邮件中没有个性化 To: headers.

警告:编辑内容如下:

我确实提交了 Office 365 支持请求(因为我是企业订阅者,我希望这意味着什么)请求他们添加对存储 RCPT TO 信封地址的支持,但它被抛出进入积压 ,因此永远不会发生 。这是 Microsoft 坚决拒绝采用的 e-mail 系统的另一个血腥明显的功能,就像一次性地址、消息标记、内联引用回复、将邮箱与用户分开以及 tree-view 用于对话线程一样 - and more besides。哎呀呀

我在另一篇 SO 文章中发现了这个:Can you get PR_TRANSPORT_MESSAGE_HEADERS 0x007D from the .Net Microsoft Graph API?

这将 return 您需要的 headers