Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

office365 - How can I retrieve the full MIME message from an Microsoft Outlook Add-In?

I am developing an Outlook Web Access Add-In in which I want to access all the data of an email including sender address, recipient address, subject and sent date etc. I also want to download the entire message file. I have found one Outlook Web REST API but don't know how to use it.

Can anyone explain how to use this API to retrieve the entire MIME message and provide an example?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess you want to get the current email in MIME format (aka *.eml file type). If so, see the answer.

1. Exchange Web Services (EWS). Prior 2019 year

You have to use Exchange Web Services (EWS) and there are two ways:

  1. Do it in JavaScript via makeEwsRequestAsync() method by setting IncludeMimeContent property in the request and process content of the MimeContent tag of the response (it's base64, so you may need to decode).

    But it doesn't work on iOS/Android (link) and the email size limit for JavaScript APIs is 1 MB (see all limitations of the JavaScript API), so the implementation of fetching and decoding the email must run on the back-end (which may be an unnecessary load for the server). Hence you may forget option #1 and start reading the next option.

  2. Send EWS request and process the response on the back-end. But for that you need to get a callback token (for authentication from your back-end), item ID of the email and the EWS url (see this post on how to get them in the add-in).

Having said that, there are said news. Since July 2018 Microsoft issues only security updates for EWS (see the official statement). They phase it out in favour of Microsoft Graph, the new gateway to Office data, which so far does NOT support export of email in the EML format. The feature is promised in beta by the end of 2018.

2. Microsoft Graph. Starting from 2019 year

EWS is dead and Microsoft Graph is the way to go. The Microsoft folks promised to expose the entire email MIME stream in Outlook Mail REST API (should be in beta by now). So keep an eye on Outlook mail REST API.

Note: MS Graph works only with Exchange Online (Office 365 in the cloud) or on Exchange on-premises in a hybrid deployment (requires at least Exchange 2016 Cumulative Update 3 (CU3) on-premises server integrated with Office 365).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...