Missing subject and sender when converting to pdf

I’m currently trying to convert emails to PDFs for a project I’m working on. I found some code snippets online, but when running the code the PDFs do not contain the subject lines, or the sender.
Email to PDF Code Snippet.png (42.1 KB)

Test Email.pdf (79.1 KB)

Email Example.PNG (22.4 KB)

@rkess

Can you please share the email file in .zip archive with us as well so that we can test the scenario in our environment and address it accordingly?

Test Email.zip (4.5 KB)

@rkess

If possible, can you please also share an expected output sample that you wish to obtain after conversion? We apologize for the over communication.

Email PDF.pdf (259.0 KB)

Doesn’t have to look exactly like this, just need to be able to see the sender, recipients, subject, and body within the pdf. Currently only the body is showing in the file.

@rkess

Looks like you need to convert the .msg file into PDF with custom format. We believe that this requirement is specifically related to Aspose.Email and there can be some workaround to achieve what you expect. Therefore, we are moving it to respective forum category where you will be assisted accordingly.

Hello @rkess ,

As a solution to your problem, we suggest that you should use HtmlFormatOptions.WriteHeader enum:

var htmlSaveOptions = Aspose.Email.SaveOptions.DefaultHtml;
htmlSaveOptions.HtmlFormatOptions = HtmlFormatOptions.WriteHeader;

msgTest.Save(htmlFileTest, htmlSaveOptions);

Please spare a minute to share your feedback with us. If you have any more questions or need further assistance, feel free to ask.

Seems to have worked. Thank you.

Hello @rkess ,

Thank you for the feedback. If you have any more questions or need further assistance, feel free to ask.