We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert eml to MSG format


Currently we are facing issue on production while converting eml to msg format in java web application.

previously we are downloading the eml file after clicked the "Open" button on front end.

We are getting byte array of eml file. so we want convert this byte array into MSG format.

Could you please provide the solution for this requirement?

Thanks in advance.



Hi Subramanum,

Please refer to the following
code sample for converting EML Byte Array to MSG format. The sample code
assumes that the EML is saved to Byte Array which is then loaded in
ByteArrayInputStream, loaded in MailMessage and then saved to disc as
MSG format. Please let us know if we can be of any additional help to
you in this regard.

Sample Code:

//We assume that the ostream contains the message saved in EML format

ByteArrayInputStream istream = new ByteArrayInputStream(ostream.toByteArray());

MailMessage msg = MailMessage.load(istream, MailMessageLoadOptions.getDefaultEml());

msg.save(“Output.msg”, MailMessageSaveType.getOutlookMessageFormatUnicode());

Hi Kashif,

Thanks for your response.

I will do the changes as per your suggestion and update to you asap.


RSY Narayan

Hi RSY Narayan,

Thank you for the acknowledgement and feel free to write us back if you have any other query in this regard.


Thanks for your information.

By using latest aspose email jar file (aspose-email- I downloaded the jar file from below link-


I converted EML to MSG format successfully. Please check below code- file from below lin

ByteArrayOutputStream oStream2 = new ByteArrayOutputStream();
if(extn != null && extn.equalsIgnoreCase(".eml")){
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
ByteArrayInputStream istream = new ByteArrayInputStream(oStream.toByteArray());
MailMessage msg = MailMessage.load(istream, MailMessageLoadOptions.getDefaultEml());
msg.save(oStream2, MailMessageSaveType.getOutlookMessageFormatUnicode()) ;
documentData = oStream2.toByteArray() ;
extn = “.msg” ;
}catch(Exception ex){
System.out.println(" exception = "+ex.getLocalizedMessage());

Now I am facing issue that Evaluation Copy message is showing while opening MSG format document.

Could you please suggest to me why that message is showing inside the document.?

RSY Narayan

Hi Narayan,

The evaluation message means that you haven’t initialized license in your application or your license is expired. Please verify in your application that you are properly referencing the license file. If the license is referenced correctly, then please check the subscription expiry of your license. Let us know if we can be of any additional help to you in this regard.

Hi Kashif,

Thanks for your help.

As per your suggestion, I had tested with temporary aspose total license for converting EML to MSG format and it is properlly working.

So you can close the issue.


RSY Narayan

Hi Narayan,

Thank you for sharing your feedback and please feel free to write to us for any additional query related to Aspose.Email.