我正在开发的一个应用程序需要访问电子邮件的标题——特别是像 return-path
这样的标题。 , in-reply-to
, 和 references
.理想情况下,我们希望能够访问电子邮件的所有 RFC 2822 header 。 Outlook/Office 365 REST API 是否可以做到这一点?如果没有,是否可以使用任何 API?
最佳答案
更新: InternetMessageHeaders
属性已添加到 Outlook API 的 beta 端点,因此您无需使用扩展属性即可获得此属性。您必须通过 $select
明确请求该属性。尽管。就像是:
GET https://outlook.office.com/api/beta/me/mailfolders/inbox/messages?
$select=Subject,InternetMessageHeaders
对于图表:该属性也存在于 Graph 的 beta 端点中的消息中,因此您可以执行以下操作:
GET https://graph.microsoft.com/beta/me/mailfolders/inbox/messages?
$select=subject,internetMessageHeaders
对于非 beta 端点:API 不直接提供访问权限。但是,您可以访问 PidTagTransportMessageHeaders使用 Extended Property API 的 MAPI 属性.
从第一个链接中,我们看到
PidTagTransportMessageHeaders
的属性 ID是 0x7D
, 类型为 String
.所以$expand
您的 GET 参数如下所示:$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x7D')
NOTE: This is only applicable for the Outlook endpoint (https://outlook.office.com). For Graph, see the answer from madsheep
将其与
GET
放在一起对于特定消息,您的请求可能如下所示:GET https://outlook.office.com/api/v2.0/me/messages/{message-id}?
$select=Subject,SingleValueExtendedProperties
&$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x7D')
关于outlook-restapi - 是否可以使用 Outlook/Office 365 REST API 从电子邮件中检索 RFC 2822(或任何) header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38103388/