+2 votes

I did this little development to test:

string fileName = "c:\\FW NVAX - Documentação para entrega de primeira release em QA.msg";

using (var converter = new MsgConverter(fileName))
{
    if (converter.Type == MsgType.Note)
    {
        IMail email = converter.CreateMessage();

        foreach (MimeData mime in email.Attachments)
        {
            if (Path.GetExtension(mime.SafeFileName) == ".xlsx")
               mime.Save("c:\\" + mime.SafeFileName);
            email.RemoveAttachments();
            email.Save("c:\\FWNVAX.msg");
        }
    }

and it works, but when I try to open the new msg file it send show this message:
"Cannot start Microsoft outlook. Cannot open file C:\FWNVAX.msg ...".

This just happens with msg files. With eml files it works ok.

by

1 Answer

0 votes
 
Best answer

IMail.Save doesn't use msg file format. It uses MIME eml file format. Saving msg files is not supported. Your code should look like this:

email.Save("c:\\FWNVAX.eml"); // note the extension

.eml files can be opened inside MS Outlook for viewing (supported by Outlook 2003 and above).

It is enough to set the Outlook to be default email client and double
click to the .eml file to open it.

That will not import EML file to Outlook.

To transfer .eml file you should drag the email file to any Outlook
folder and the drop it (release the mouse button). Outlook will open dragged email message and you will be able to save it inside desired folder.

In Microsoft Office Outlook 2007 you may need to install this hotfix:
http://support.microsoft.com/kb/956693/en

by (301k points)
...