I’ve been testing Aspose.Total for Java. When converting MSG file with PDF attachments to PDF I used the following code:
// Load MSG in Aspose.Email for Java String input = ...; // input file path FileInputStream inputStream = new FileInputStream(input); com.aspose.email.MailMessage eml = com.aspose.email.MailMessage.load(inputStream); // Save the Message to output stream in MHTML format ByteArrayOutputStream emlStream = new ByteArrayOutputStream(); com.aspose.email.MhtSaveOptions saveOptions = com.aspose.email.SaveOptions.getDefaultMhtml(); saveOptions.setSaveAttachments(true); eml.save(emlStream, saveOptions); // Load the stream in Word document with Aspose.Words for Java com.aspose.words.LoadOptions lo = new com.aspose.words.LoadOptions(); lo.setLoadFormat(com.aspose.words.LoadFormat.MHTML); com.aspose.words.Document doc = new com.aspose.words.Document(new ByteArrayInputStream(emlStream.toByteArray()), lo); // Save to disc String output = ...; // output file path doc.save(output, com.aspose.words.SaveFormat.PDF); System.out.println("\nEmail file converted to PDF successfully.\nFile saved at " + output);
All I got was the email without attachments. What went wrong?
Are PDF attachments not supported by Aspose.Email for Java, Aspose.Words for Java or both?
What formats of attachments in MSG are supported?
What are alternative actions in Aspose.Total for Java to handle this case?
I was using Aspose.Email for Java 21.5, Aspose.Words for Java 21.6 and JDK 1.8.