Converting Mapimessage to MailMessage - result file corrupted


#1

Hi,


We use MapiMessage in all our operations for working with message properties and then need to convert it to EML. Currently, we save the MapiMessage to memorystream and then load MailMessage from it for saving to EML. Is it the right way, as we get corrupt output files in result.

#2

Hi Robert,


Thank you for writing to Aspose Support team.

The proper way to convert MapiMessage to EML is using the Interpret method of MailMessageInterpretor as shown in the following code sample. Please try it at your end and let us know your feedback if you face any issue while using this conversion method.

Sample Code:

MapiMessage mapiMsg = MapiMessage.FromFile(“some msg file.msg”);

MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(mapiMsg.MessageClass);

MailMessage mailMsg = mi.Interpret(mapiMsg);

mailMsg.Save(“save as EML.eml”);

#3

MapiMessage mapiMsg = MapiMessage.FromFile(“some msg file.msg”);

MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(mapiMsg.MessageClass);

MailMessage mailMsg = mi.Interpret(mapiMsg);

mailMsg.Save(“save as EML.eml”);

This Code is not working in java.18.9.4 email


#4

@pradeepnegi,

Thank you for contacting Aspose Support.
Please use the code snippet given below to convert MSG to EML.

MapiMessage mapiMsg = MapiMessage.fromFile("Email.msg");
mapiMsg.save("Email.eml", EmlSaveOptions.getDefaultEml());

We hope that this resolved the issue that you were facing. Please feel free to reach us if additional information is required.