Outlook Rest API:使用 Outlook Rest API 下载 .eml 文件类型的电子邮件附件文件类型、邮件附件、电子、Rest

2023-09-06 17:09:57 作者:爱的卑微才心痛.

我关注了

如果电子邮件附件类型是 FileAttachment,我可以在 api 响应中获取文件内容并能够保存附件.如果电子邮件附件类型是 ItemAttachment,我无法在 api 响应中获取文件内容.当我搜索它时,我发现 this 堆栈溢出问题.我使用了答案中提到的其余 API.但它以 html 格式提供 itemAttachment 内容.如果该 ItemAttachment 中有任何 fileattachment ,那么我将无法访问它.

开发REST API

是否有任何 API 可用于将 itemAttachment 下载为 .eml 文件而不是 html?

欢迎任何建议/答案.

解决方案

我假设 .eml 你的意思是你想检索 MIME 格式的电子邮件?

Microsoft Graph API 目前不支持检索电子邮件的原始 MIME 内容.这是一个常见的请求,并且现有 UserVoice 请求它.

如果这是您的方案的硬性要求,您可能需要了解一下 Exchange Web 服务 (EWS).Message 对象返回EWS 包括 MimeContent 属性.

I followed this documentation to download the attachments of email.

Below is the API response.

If email attachment type is FileAttachment, I am able to get the file content in api response and able to save the attachment. If email attachment type is ItemAttachment, I am not able to get the file content in api response. When I googled for it, I found this stack overflow question. I used the rest API mentioned in the answer. But it's giving itemAttachment content in html format. And if that ItemAttachment has any fileattachment in it, then I am unable to access it.

Is there any API available to download the itemAttachment as .eml file not as html?

Any suggestion/answers would be more than welcome.

解决方案

I assume by .eml you mean you'd like to retrieve the email in MIME format?

Retrieving an email's raw MIME content isn't supported by Microsoft Graph API at this time. This has been a common request and there is an existing UserVoice request for it.

If this is a hard requirement for your scenario, you may want to take a look at Exchange Web Services (EWS). The Message object returned by EWS includes a MimeContent property.