Question: I have a C# application that reads .msg files and extracts the body and the attachments. But when I try to load a .eml file the application crashes. I am loading the files like this:

```
MailItem mailItem = (MailItem)outlookApp.CreateItemFromTemplate(msgFileName);
mailItem.SaveAs(fullFilename, OlSaveAsType.olHTML); // save body in html format
for(int i = 0; i < mailItem.Attachments.Count; i++)
    mailItem.Attachments[i].SaveAsFile(filename); // save attachments

```

This works fine with .msg files, but it doesn't work for .eml files. I don't understand why .eml files don't work, because I can open .eml files in Outlook 2010.

How can I load .eml files using the Outlook [Primary Interop Assembly](http://msdn.microsoft.com/en-us/library/aax7sdch.aspx)?

Answer: 
Try this sample code [Easily Retrieve Email Information from .EML Files](http://www.codeproject.com/KB/office/EML_Reader.aspx)
`CreateItemFromTemplate` only works with the MSG/OFT files.
Fot the EML files you will either need to parse the file explicitly in your code or use a third party library (such as Redemption - I am its author):

The following code will create an MSG file and import an EML file into it using [Redemption](http://www.dimastr.com/redemption) ([RDOSession](http://www.dimastr.com/redemption/rdosession.htm) object):

```
  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = outlookApp.Session.MAPIOBJECT
  set Msg = Session.CreateMessageFromMsgFile("C:\Temp\temp.msg")
  Msg.Import "C:\Temp\test.eml", 1024
  Msg.Save
  MsgBox Msg.Subject

```

You can then use the message ([RDOMail](http://www.dimastr.com/redemption/RDOMail.htm)) to access it various properties (Subject, Body, etc.)