Office outlook web(AddIn) dowloand message file

女生的网名这么多〃 提交于 2020-01-13 07:18:07

问题


Hei Iam developing Outlook web addIn in which i want to access all the data of email ,Senderemail, receipent email ,subject and sent date etc. I also want to download the entire message file .I have found one outlook web REST api

https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations#GetMessage

but dont know how to use it. Anyone has experience with that ? If anyone can share any example it would be helpful Thanks


回答1:


1. To get the message details you can use the javascript APIs available in office.js. Refer the link for details on individual APIs that are available on an item:

https://dev.office.com/reference/add-ins/outlook/1.5/Office.context.mailbox.item?product=outlook&version=v1.5

2. To get the entire message file. GetMessage API does not provide you with a .msg file but it will fetch you all the properties of the message, you can use this to get extra details about the message which are not provided by the javascript APIs directly.

3. There is a way to get a .eml file using the following two steps:

Step1: Get a EWS callback token using the JS API getCallbackTokenAsync([options], callback). Refer link:

https://dev.office.com/reference/add-ins/outlook/1.5/Office.context.mailbox?product=outlook&version=v1.5

Step2: With this token from your server make an EWS request to get the item with IncludeMimeContent set to true and save the response as a .eml file. Refer link:

https://msdn.microsoft.com/en-us/library/office/aa566013(v=exchg.150).aspx




回答2:


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).



来源:https://stackoverflow.com/questions/44631907/office-outlook-webaddin-dowloand-message-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!