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?
Try this sample code Easily Retrieve Email Information from .EML Files