使用 Office 365 REST API 时,在 X-AnchorMailbox header 的 UpnName 和 SmtpAddress 之间进行选择

Choosing between the UpnName and SmtpAddress for the X-AnchorMailbox header when using Office 365 REST API

我们使用带有 Azure AD 身份验证的 Outlook REST API 来访问我们用户的邮箱。 documentation推荐使用x-AnchorMailboxheader来优化性能:

For optimal performance when using the new Outlook REST endpoint, add an x-AnchorMailbox header for every request and set it to the user's email address. For example: x-AnchorMailbox:john@contoso.com

对于给定的用户,我们应该使用 主 SMTP 地址(可能会更改)还是 UPN 名称

有多种代码示例使用这些技术(如 this),但它使用的 EmailAddress 可能不明确。

您应该将此设置为用户的 EmailAddress 属性(从 API 的 /Me 端点获得)。