当我在 office365 网络浏览器页面中打开电子邮件时,有一个选项可以下载附加到此电子邮件的内容itemAttachment(使用 Microsoft Outlook 附加到当前邮件的另一封邮件)- * .eml 文件,(内容类型:RFC-822)。
但是,当我尝试通过 Graph API(相同操作)获取此 itemAttachment 的内容时,contentBytes 响应属性不存在。
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('bbbbb')/messages('fffff')/attachments",
"value": [{
"@odata.type": "#microsoft.graph.itemAttachment",
"id": "gggg",
"lastModifiedDateTime": "2017-02-13T16:29:45Z",
"name": "The Daily Build - Compiling your C code to .NET",
"contentType": "message/rfc822",
"size": 99129,
"isInline": false
}
]
}
关于如何通过 Graph API ( contentType=itemAttachment ) 获取附加 outlook 消息内容的任何想法? fileAttachment contentType 工作正常,我可以从 Graph API 响应的 contentBytes 属性中获取内容。考虑以下 API 端点:
https://graph.microsoft.com/beta/me/messages/{id}/attachments
https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}
https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}?$expand=#microsoft.graph.itemAttachment/item
以上都不返回附加项目的内容。
最佳答案
它处于测试阶段并且没有文档,但您可以使用 Microsoft Graph API 获取 MIME 内容:
GET https://graph.microsoft.com/beta/me/messages/{id}/$value
或
GET https://graph.microsoft.com/beta/users/{id | userPrincipalName}/messages/{id}/$value
附件:
GET https://graph.microsoft.com/beta/users/{id}/messages/{id}/attachments/{id}/$value
根据响应,您可以创建一个扩展名为 .eml 的文件。
编辑:
现在正式预览:https://learn.microsoft.com/en-us/graph/outlook-get-mime-message
关于outlook - Microsoft Azure Graph API 下载项附件内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42210430/