Scenario: I open EML message in with MailMessage class. EML message contains winmail.dat MIME part. I need to work with some MAPI properties, so I read MapiMessage from MailMessage. Then I save message to MSG format usin MapiMessage object.
Issue: Outlook cannot open generated MSG file: "Cannot read the item" error message appears. When I change extension to ".eml", Outlook will open it, but will display "winmail.dat" attachment instead of image (see original message attached).
I know that I can save message to MSG format using MailMessage class, but I work with MapiMessage object and need to use it for saving.
Code:
using (var mail = MailMessage.Load(File.OpenRead("sample.eml"), new EmlLoadOptions ()))
{
using (MapiMessage mapi = MapiMessage.FromMailMessage(mail))
{
//..........
mapi.Save(@"resaved.msg");
}
}