Outlook Rest API: Download the email attachments o

2020-04-19 07:20发布

问题:

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.

回答1:

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.