当我在office365网页浏览器页面中打开电子邮件时,有一个选项可以下载该电子邮件的附件内容项目附件(使用 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
}
]
}
任何想法如何通过图形 API 获取附加 Outlook 消息的内容(内容类型=项目附件)? fileAttachment contentType 工作正常,我可以从 Graph API 响应的 contentBytes 属性中获取内容。考虑以下 API 端点:
https://graph.microsoft.com/beta/me/messages/ https://graph.microsoft.com/beta/me/messages/{id}/附件
https://graph.microsoft.com/beta/me/messages/ https://graph.microsoft.com/beta/me/messages/{id}/附件/{attachmentId}
https://graph.microsoft.com/beta/me/messages/ 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
or
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 的文件。
Edit:
现在它正式处于预览状态:https://learn.microsoft.com/en-us/graph/outlook-get-mime-message https://learn.microsoft.com/en-us/graph/outlook-get-mime-message
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)