title: How to open .eml files using Outlook MAPI in C#?
body: <p>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:</p>
  
  <pre><code>MailItem mailItem = (MailItem)outlookApp.CreateItemFromTemplate(msgFileName);
  mailItem.SaveAs(fullFilename, OlSaveAsType.olHTML); // save body in html format
  for(int i = 0; i &lt; mailItem.Attachments.Count; i++)
      mailItem.Attachments[i].SaveAsFile(filename); // save attachments
  </code></pre>
  
  <p>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.</p>
  
  <p>How can I load .eml files using the Outlook <a href="http://msdn.microsoft.com/en-us/library/aax7sdch.aspx" rel="nofollow">Primary Interop Assembly</a>?</p>