The message title, sender and receiver get lost during Email to PDF convert

I use Aspose Email Java to convert a msg File to PDF file, the rendering result is good, however, only Email body get displayed, yet message title, sender and receiver disappear on PDF.

Here it is the msg test file, because this forum doesn’t support msg file upload, so I zip it
guntherMails.zip (2,3 MB)

Here it is the PDF result
guntherMails.pdf (118,3 KB)

My code is so

final MailMessage message = MailMessage.load(emailFilename);
message.save("TempHtmlOutput.html", com.aspose.email.SaveOptions.getDefaultHtml());
final Document document = new Document("TempHtmlOutput.html");
document.save(targetPDFname, SaveFormat.PDF);

@zwei Please use Mhtml format as an intermediate format:

com.aspose.email.MailMessage msg = com.aspose.email.MailMessage.load("C:\\Temp\\in.msg");
msg.save("C:\\Temp\\tmp.mhtml", com.aspose.email.SaveOptions.getDefaultMhtml());
com.aspose.words.Document doc = new com.aspose.words.Document("C:\\Temp\\tmp.mhtml");
doc.save("C:\\Temp\\out.pdf");

out.pdf (62.4 KB)

1 Like

Thank you very much!

I use Aspose Email to list and download all attachments of the msg file, it the same test msg file in this topic thread.

There are 4 attachment files, however Aspose Email can only find 3 of them. The Attachment “1001.zip” can not be found by Aspose Email.

During debug, the value of “msg.getAttachments().size()” is 3, although it should be 4!

I use following code:

final MapiMessage msg = MapiMessage.fromMailMessage(emailFilename);
final String dataDir = "AsposeTemp";

for (int i = 0; i < msg.getAttachments().size(); i++) {
    //Set a reference to the MapiAttachment object
    MapiAttachment outlookMessageAttachment = (MapiAttachment) msg.getAttachments().get_Item(i);
    //Display attachment type
    System.out.println("Att Type : " + outlookMessageAttachment.getMimeTag());
    //Display attached file name
    System.out.println("File Name : " + outlookMessageAttachment.getLongFileName());
    //Save attachment to the disk
    outlookMessageAttachment.save(dataDir + outlookMessageAttachment.getDisplayName());
}

Hello @zwei ,

Let us inform you that in the evaluation mode, the number of attachments is limited to three. The license is required.

1 Like

Thank you very much! We have an Aspose Total License, and i will try licensed edition.

You’re welcome @zwei!

We appreciate your interest in our product.

1 Like