Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to Convert Email Messages to EML, MSG & MHTM Formats in Android Apps

sheraz786sheraz786 Posts: 17Member

This technical tip shows how to convert email messages to another format using Aspose.Email for Android API. Aspose.Email API has made very easy to convert any message type to another format. To demonstrate the simplicity of this feature, this article shows how to load three different types of messages from disk and save them back in other formats. To modify an existing email message:

• Create an instance of the MailMessage class. • Load the existing email message using the load() method exposed by the MailMessage class and specifying the correct MessageFormat. • Save the message to disk by using the save() method exposed by the MailMessage class and specifying the corr

Load EML and Save to MSG and MHTML

public static void ConvertFromEML() { // Base folder for reading and writing files String strBaseFolder = Environment.getExternalStorageDirectory().getPath(); strBaseFolder = strBaseFolder + "/";

//Initialize and Load an existing EML file by specifying the MessageFormat
MailMessage msg = MailMessage.load(strBaseFolder + "AnEmail.eml", MessageFormat.getEml());

//Save the Email message to disk by specifying the MSG and MHT MailMessageSaveType
msg.save(strBaseFolder + "message.msg", MailMessageSaveType.getOutlookMessageFormat());
msg.save(strBaseFolder + "message.mhtml", MailMessageSaveType.getMHtmlFormat());

}

Load MSG and Save to EML and MHTML

public static void ConvertFromMSG() { // Base folder for reading and writing files String strBaseFolder = Environment.getExternalStorageDirectory().getPath(); strBaseFolder = strBaseFolder + "/";

//Initialize and Load an existing MSG file by specifying the MessageFormat
MailMessage msg = MailMessage.load(strBaseFolder + "AnEmail.msg", MessageFormat.getMsg());

//Save the Email message to disk by specifying the EML and MHT MailMessageSaveType
msg.save(strBaseFolder + "message.eml", MailMessageSaveType.getEmlFormat());
msg.save(strBaseFolder + "message.mhtml", MailMessageSaveType.getMHtmlFormat());

}

Load MHTML and Save as EML and MSG

public static void ConvertFromMHTML() { // Base folder for reading and writing files String strBaseFolder = Environment.getExternalStorageDirectory().getPath(); strBaseFolder = strBaseFolder + "/";

    //Initialize and Load an existing MHT file by specifying the MessageFormat
MailMessage msg = MailMessage.load(strBaseFolder + "AnEmail.mhtml", MessageFormat.getMht());

//Save the Email message to disk by specifying the EML and MSG MailMessageSaveType
msg.save(strBaseFolder + "message.eml", MailMessageSaveType.getEmlFormat());
msg.save(strBaseFolder + "message.msg", MailMessageSaveType.getOutlookMessageFormat());

}

Tagged:
Sign In or Register to comment.