We are using your the following code to convert MSG to PDF -
ByteArrayOutputStream result = new ByteArrayOutputStream();
try {
log.info(“Initiating Email to pdf conversion”);
MailMessage mailMsg = MailMessage.load(emailInputStream);
// converting mailMsg to HTML (aspose doesn’t support direct eml -> pdf conversion)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mailMsg.save(baos, SaveOptions.getDefaultMhtml());
// loading HTML into Aspose.Words Document
LoadOptions lo = new LoadOptions();
lo.setLoadFormat(LoadFormat.MHTML);
Document document = new Document(new ByteArrayInputStream(baos.toByteArray()), lo);
// finally saving Document as PDF.
document.save(result, SaveFormat.PDF);
return result.toByteArray();
} catch (Exception ex) {
log.error("Exception occurred while converting Email to pdf :", ex);
throw ex;
} finally {
result.close();
}
We have converted the shared EML to MHTML using Aspose.Email for Java and have not found any issue with output MHTML. Please check the output. output.zip (27.9 KB)
Could you please share your problematic output PDF along with screenshots of problematic sections of output? We will investigate this issue further and provide you more information onit.
The output you have provided is clearly incorrect if you compare with the email I had attached earlier. asp.zip (197.3 KB)
screenshots showing the discrepancy.
We opened the output MHTML in MS Word 2019. The output looks good. MS Word 2019.png (99.1 KB)
However, the output looks incorrect in Internet Explorer. We have logged this issue in our issue tracking system as EMAILNET-40726. You will be notified via this forum thread once this issue is resolved.
We have closed the issue EMAILNET-40726 as ‘Not a Bug’. Aspose.Email does not change html body in any way. You can save message to HTML and see correct result.
This is known issue with different html rendering engines for IE and MS Office. If you open output MHT file in MS Word instead IE you will be able to see expected result.
We suggest you please read the following articles.