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

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. Aspose.Email for Android API enables developers to design Android applications for managing & manipulating Outlook email file formats without using MS Outlook. It provides tools to create, read & convert Outlook MSG, PST, EML, EMLX, OST & MHT file formats.
//your code here...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()); }

Url: http://www.aspose.com/docs/display/emailandroid/Converting+Email+Messages

Language: Java | User: Sheraz Khan | Created: Aug 27, 2014 | Tags: Load EML and Save to MSG convert EML to MHTM Load MSG and Save to EML convert MSG to EML & MHTML convert MHTML messages to MSG android email API Outlook Android component