.eml to .msg conversion

Hello,

We are currently evaluating the aspose.network product for .eml conversion to .msg (outlook).
we have .eml messages stored in database and also in sharepoint. We want convert to these messages without storing them on the disk. One of the example is messages are read from the disk and saved back to disk using following code:

MailMessage eml = MailMessage.Load(“test_email.eml”);
MapiMessage msg = MapiMessage.FromMailMessage(eml);
msg.Save(“test_email2.msg”);

Save method for the MapiMessage is defined as void which means we have write to a disk. Is there any possibility to save this message as stream object so that we can save it to database without downloading to the disk?

Thanks.


Hi,

Thanks for considering Aspose.

You can also save the message to stream using the overloaded method of MapiMessage.Save(). The sample code below converts eml to msg, saves to stream and again create the MapiMessage from the stream.

MailMessage eml = MailMessage.Load(@“test.eml”);
MapiMessage msg = MapiMessage.FromMailMessage(eml);
MemoryStream stream = new MemoryStream();
msg.Save(stream);
stream.Position = 0;
MapiMessage msgLoad = MapiMessage.FromStream(stream);
Console.WriteLine(msg.Subject);