Microsoft Azure Graph API 下载项附件内容 [英] Microsoft Azure Graph API download itemAttachment content
问题描述
当我在 office365 网页浏览器页面打开电子邮件时,有一个选项可以下载此电子邮件附件的内容 itemAttachment(使用 Microsoft Outlook 附加到当前邮件的另一封邮件) - *.eml 文件,(内容类型:RFC-822).
When I open email message in the office365 web browser page, there is an option to DOWNLOAD contents of the attached to this email itemAttachment ( another message attached to the current one using Microsoft Outlook ) - *.eml file, (contentType: RFC-822).
但是,当我尝试通过 Graph API(相同操作)获取此 itemAttachment 的内容时, contentBytes 响应属性不存在.
However, when I'm trying to get the contents of this itemAttachment through Graph API (same operation), the contentBytes response property is not present.
{
"@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 端点:
Any ideas how to get contents of attached outlook message though Graph API ( contentType=itemAttachment )? The fileAttachment contentType is working fine, I can grab the contents from the contentBytes property of the Graph API response. The following API endpoints are considered:
https://graph.microsoft.com/beta/me/messages/{id}/附件
https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}
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
https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}?$expand=#microsoft.graph.itemAttachment/item
以上都没有返回附加项目的内容.
neither of the above returns contents of the attached Item.
推荐答案
它处于测试阶段,没有文档,但您可以使用 Microsoft Graph API 获取 MIME 内容:
It's in beta and there isn't a documentation, but you can get MIME content with Microsoft Graph API:
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 的文件.
With the response you can create a file with .eml extension.
现在正式预览:https://docs.microsoft.com/en-us/graph/outlook-get-mime-message
这篇关于Microsoft Azure Graph API 下载项附件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!