Last active
October 17, 2022 15:00
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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