Difference between a .msg file and a .eml file

rajesh picture rajesh · Apr 26, 2013 · Viewed 26.3k times · Source

What are the difference between a .msg file and a .eml file?

  1. I know that eml is infact a text file while msg is not.
  2. Both can be opened in Outlook.
  3. Outlook allows you to save the email as .msg but I didnt find an option to save as an eml

Is there anything that msg is capable and which eml is not and vice versa?

Answer

Dmitry Streblechenko picture Dmitry Streblechenko · Apr 26, 2013

MSG is a binary OLE storage file (IStorage). Unlike MIME (EML), it stores all MAPI specific properties that MIME cannot store. It's format is documented by Microsoft. You can look inside an MSG file on the IStorage level using a utility like SSViewer. On the MAPI level, you can open/create an MSG file using StgOpenStorage / StgCreateStorageEx and OpenIMsgOnIStg functions. You can see properties stored inside an MSG file in OutlookSpy (click OpenIMsgOnIStg button).

EML files are text files in the MIME format (you can open a file like that in Notepad).

To create an EML file, you can either

  1. Create it explicitly in your code one MIME header/part at a time.

  2. If you are using Extended MAPI in C++ or Delphi, you can use the IConverterSession interface that wraps the native Outlook converter. You can play with it in OutlookSpy - click IConverterSession button on the OutlookSpy toolbar.

  3. You can use Redemption and its RDOMail.SaveAs(..., olRfc822) / SafeMailItem.SaveAs(..., olRfc822) methods.