About: EWS/REST/Graph and MSG files

EWS, REST and Graph can save and load MSG file attachments to items such as email. However, they cannot create, update or parse .MSG files.  These APIs are Exchange based and don't know about and have never supported creating, loading or parsing MSG files.  MSG files are Outlook data storage files and only Extended MAPI and Outlook Object Model (OOM) APIs are supported with them.  Both OOM and MAPI need Outlook to be installed.  OOM is an automation API for Outlook, which is a user desktop application and needs to have a user present when its automation API (OOM) is used.  Extended MAPI is a messaging sub-system which is installed with Outlook – so Outlooked must be installed on the machine where MAPI is used.

Outlook's MSG files are not in full fidelity (i.e. having full properties of items) and neither is .EML (email MIME). If you wanted to do something like move items from one mailbox to another then you could use EWS to extract an email as a blob (EWS ExportItems) and load it on another mailbox for review (EWSUploadItems).  A document review system could store such a blob for later import into a mailbox and also contain items properties to be displayed to a user for review.  The format for these blobs is not documented, so there is no support for parsing them with custom code   However, it's very important to understand that these blobs contain the full fidelity of properties for an item – this is something unique to EWS at this point; however, keep an eye on REST and Graph in this type of feature gets added in the future (I have no info on if or if not it will be added).

Note that EWS has a special method which can convert between EWS IDs, IDs of MAPI and Outlook.  This means you can mix EWS/MAPI/OOM API to some extent. For all APIs you should be able to use the StoreId of items between the different APIs.  One common mix is to use them in a custom add-in in Outlook.

If you are thinking of using the old Exchange MAPI: There were once two MAPIs… Long ago there was a version of Extended MAPI which was part of Exchange and could be downloaded – however, we have not supported that version of MAPI for a very long time.  This download was created due to customers wanting to use it on Exchange 2007.  See, earlier versions of Exchange installed Extended MAPI and those versions of Exchange used it.  Exchange 2007 was a huge rewrite of Exchange and a lot of its existing code was replaced and it was no longer MAPI based.  MAPI was removed as an installed API also.  Some customers had MAPI applications they wanted to use on their Exchange server, so the Exchange product team created the Exchange MAPI download as a stop-gap API to give customers a chance to update their code to use the newer APIs (EWS and PowerShell).  The Exchange download version of MAPI is no longer supported. So, in the end you will need to have Outlook installed to work with MSG files. Also note that OOM is only supported in a user session where a user can interact with dialogs which might be displayed – it's not supported in a background session which would include apps like page, windows services or web services.


Here are the EWS calls which can save and load items using EWS:

               How to: Export items by using EWS in Exchange

               How to: Import items by using EWS in Exchange

Custom code:

MSG files can be created programmatically using one of our APIs or through custom code.  The custom code approach is not supported.  You could write custom code to create an MSG file, using data you extracted separately from an item using EWS.  However, there is no developer support for creating an MSG file in this manner.

[MS-OXMSG]: Outlook Item (.msg) File Format

.MSG File Format (Part 1)


It's better to use Outlook Object Model (OOM) or Extended MAPI to create an .MSG file.  OOM code needs to be run with a user present who can respond to dialogs – it's not supported in a background process.  OOM can be used with .Net language, unmanaged languages such as C+ and also by scripting languages.  Extended MAPI code needs to be used in unmanaged code – such as C++; it's not supported under .NET.  Both APIs are only supported on a machine where Outlook is installed because they require Outlook to be installed (MAPI needs Outlook's MAPI subsystem and OOM needs Outlook).

About: Outlook Object Model (OOM)

About: Extended MAPI

OOM can save and load items to file as MSG:

Looking for a way to save a .msg file or load a .msg file?

OlSaveAsType Enumeration (Outlook)

MAPI to MIME conversion API:

With unmanaged code (C++, etc.) on a machine having Outlook installed you can use the MAPI to MIME Conversion API.  This API can import an MSG into Outlook or export and email to an MSG file.

About the MAPI-MIME Conversion API

Unicode MSG Files

No MSG For You!

IConverterSession : IUnknown

Note: If you export to EML then covert to an MSG file you will have roughly the same data in the MSG file.

Third Party APIs which work with MSG files:

If you are considering a third-party API then please understand that those would need to be provided by the vendor who created them.

Working with attachments – EWS:

How to extract exchange attachments using Exchange Web Services and VB.NET

Attachments and EWS in Exchange

Getting attachments by using the EWS Managed API 2.0

Working with attachments by using the EWS Managed API 2.0

Working with attachments – Graph:

    Attachment resource type

Working with attachments – REST:

Outlook Mail REST API reference


Comments (0)

Skip to main content