We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Email subject prevents correct convertion to PDF, signed emails


having problems while trying to convert a signed email with specific email subject to PDF. After the conversion we get complete email message text, instead of just email content

Attached is the test class SimpleEmailTest.java and test emails: simpleemail.eml, simpleemail-differentsubject.eml. Screen of the PDF document being generated: simpleemail.pdf.png

the difference between the emails is the subject:

$ diff simpleemail-differentsubject.eml simpleemail.eml
< Subject: Test

we are using Aspose versions 17.9. Please not if we disable the license we get better PDF with email content being extracted next to License warning watermark

All files simpleemail.zip (79.5 KB)

Thank you,


Please try it with the latest version of Aspose.Email for Java 18.7. We have tested this at our end with this version and couldn’t observe the problem. Let us know your feedback then.


I had to request a temporary license to get access for the latest Aspose package. The issue still persists. I have generated following files with Aspose of version 18.7, below are both files generated with license applied and without it, please not that we get better transformation without license applied:

simpleemail.pdf (33.6 KB)
simpleemail-withoutlicense.pdf (56.1 KB)

Thank you,


We tried the following code at our end and the output generated with latest API doesn’t exhibit any such problem as you have mentioned. There is a little change while saving the EML to Byte Array where we have added the SaveOptions.getDefaultMhtml() option. Please try it at your end and let us know your feedback.

Sample Code

MailMessage eml = MailMessage.load("181254\\simpleemail.eml");

ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
eml.save(dstStream, SaveOptions.getDefaultMhtml());

ByteArrayInputStream srcStream = new ByteArrayInputStream(dstStream.toByteArray());

Document document = new Document(srcStream);

document.save("181254\\simpleemail.pdf", SaveFormat.PDF);

eml = MailMessage.load("181254\\simpleemail-differentsubject.eml");

dstStream = new ByteArrayOutputStream();

eml.save(dstStream, SaveOptions.getDefaultMhtml());

srcStream = new ByteArrayInputStream(dstStream.toByteArray());

document = new Document(srcStream);

document.save("181254\\simpleemail-differentsubject.pdf", SaveFormat.PDF);


I have shared the compile-able source code for the submitted issue, SimpleEmailTest.java. If you will execute that code you will reproduce the issue even with the newest Aspose 18.7

As you have mentioned the main difference is the save option that you’ve added:


The resulted PDF document is not exactly the same as now the PDF includes also email information: From, Sent, To, Subject, Attachments. If we don’t specify the SaveOptions.getDefaultMhtml() we get only email content.

Issue still persist but shared alternative could be a viable workaround, and it works with older Aspose version, testes on 18.2

Thank you,


We believe your problem is now solved with the suggested change in code. Please let us know if you still want it to be further investigated for change of behaviour.

It’s up to you, if you would like to invest more time to have a clear understanding of the issue.

for me I find the workaround acceptable


We believe the API behavior expects the save options to be specified unless saving back in EML is desired. Please use SaveOptions to get the correct results.

checked the available options. If we are using SaveOptions.getDefaultHtml() we are getting only email body content being exported - similar to the results we were getting before. SaveOptions.getDefaultMhtml() - the option you’ve shared stores also some email headers.

we get expected results for both options. We can close the topic as we do have good alternatives to choose from.

using SaveOptions.getDefaultEml() in some rare case as the one shared in this issue is not handling the messages correctly. The issue most probably is caused by some invalid characters in the subject, and the conversion performed by mentioned options above solves the issue.

Thank you Kashif for your help


Thank you for sharing your feedback and we are glad that suggested change resolved your issue. Please feel free to write to us in case you have any further query related to API.