Skip to content

Instantly share code, notes, and snippets.

How to Convert Outlook Email to HTML using Java. For further details: https://kb.aspose.com/email/java/how-to-convert-outlook-email-to-html-using-java/
import com.aspose.email.HtmlFormatOptions;
import com.aspose.email.HtmlSaveOptions;
import com.aspose.email.MailMessage;
import com.aspose.email.ResourceRenderingMode;
import com.aspose.email.SaveOptions;
public class EmlToHTMLConverter {
public static void main2(String[] args) throws Exception {// Exception for MSG to HTML conversion
String path= "/Users/KnowledgeBase/TestData/";
// Apply the product license to convert MSG to HTML
com.aspose.email.License emaiToHtmllLic = new com.aspose.email.License();
emaiToHtmllLic.setLicense(path+"Conholdate.Total.Product.Family.lic");
// Access the source MSG file from the disk
MailMessage emlMessage = MailMessage.load(path+"Message.msg");
// Set the Html rendering options for the output HTML
HtmlSaveOptions htmlOptions = SaveOptions.getDefaultHtml();
htmlOptions.setResourceRenderingMode(ResourceRenderingMode.EmbedIntoHtml);
// Apply the email message headers in the output HTML using the formatting options
htmlOptions.setHtmlFormatOptions(HtmlFormatOptions.WriteHeader |
HtmlFormatOptions.WriteCompleteEmailAddress |
HtmlFormatOptions.WriteCompleteFromEmailAddress);
// Save the loaded MSG/EML as an HTML on the disk
emlMessage.save(path+"SaveEmailAsHTML.html", htmlOptions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment