0

Is it possible to download email body and attachments in a file in .MSG format in Outlook Web? I am working on an Outlook 365 Web addin and I require to download entire message along with attachments in .MSG format?

Edit: Is there any open source library in .NET which does the same?

Thanks,

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
A.R
  • 409
  • 8
  • 21

2 Answers2

0

I have to do the same thing, but since the company I'm writting the addin for is using a version of Windows/MSOffice where the webview that the addin runs inside is handled by a IE11 process, I got OOM-error when trying to download an attachment bigger than 7MB via a EWS request (using the ews-javascript-api).

Now I'm using a IIS server to which I send the eschangeToken and EmailId and handle the download/upload of the email there via EWS-managed-api from MS.

Downloading the email as .MSG is not possible AFAIK, I download them by getting the MIME-content of the email and saving it as an .EML file.

Here MS provides some examples on how to use the ews-managed-api.

Lumpenstein
  • 1,250
  • 1
  • 10
  • 27
  • Thanks for info Lumpenstein. Our requirement is .MSG format. Is there any open source lib in C# which does it? – A.R Feb 26 '20 at 10:21
  • Unfortunately I'm not aware of such a library. .EML files have the advantage that they work with all email clients, >MSG only with outlook. [Related question](https://stackoverflow.com/questions/41227743/saving-an-email-to-a-msg-file-using-ews-managed-api/41303264) – Lumpenstein Feb 26 '20 at 12:07
0

EWS cannot convert to MSG. You can try to save in the Fast Transfer Stream format using the ExportItems EWS operation (which, just like the MSG format, preserves most properties). The EML format, on the other hand, will not preserve MAPI specific properties. The FTS data can then be converted (without any loss of fidelity) to the MSG format using Redemption (I am its author - RDOSession.CreateMessageFromMsgFile / RDOMail.Import(..., olFTS) / RDOMail.Save), but since Redemption is a native COM library, that code would have to run on your server, not inside the browser.

RDOSession session = new RDOSession();
RDOMail msg = session.CreateMessageFromMsgFile(@"c:\temp\test.msg");
msg.Import(@"c:\temp\test.fts", rdoSaveAsType.olFTS);
msg.Save();
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78