Java email msg file convert to pdf with attached files

I just downloaded trial version to make sure before purchasing.
What is the code that converts msg file to pdf file?
The attached files should be converted to pdf format and appended the main pdf file.
The attached file can be txt, doc/docx, xls/xlsx, ppt/pptx, pdf, rft, and image files.

Thanks,
Chang Shin

Hi Chang,

We are sorry for a delayed response.

Aspose.Email supports handling attachments however for conversion of these attachments to PDF requires some other Aspose products as well.

For extracting the attachments from email messages, sample code can be found at link . Once the attachments are extracted, next step is to convert them into PDF. For this purpose you may please consider the following links which contain respective sample code.

For images and text

http://www.aspose.com/docs/display/pdfjava/Technical+Articles

For PPTX to PDF

For PPT to PDF

For Excel to PDF

For Word to PDF

Your target can be achieved by using Aspose.Email in conjunction with Aspose.Pdf for Java and above mentioned products according to the requirement. If you face any problem while conversion to PDF, please contact our experts at Aspose.Pdf Product forum who will further assist you to create final PDF.

Please feel free to write us back if you have any other query related to Aspose.Email as we will be more than happy to assist you as much as possible.

Hi Kashif,

I downloaded “MsgToOtherFormats.java” code to test msg file.
How do we convert the attached files ( xls, doc, ppt, pdf,image file, vcard, and ical) automatically?
Do you have a example code?

Thanks,
Chang Shin



Hi Chang Shin,


I am afraid to inform that there is no direct method available in Aspose.Email assembly that can automatically convert different types of attachments to a single consolidated Pdf file. All the relevant products are required to convert respective file format to Pdf. You may try the code segments at links provided earlier to fulfill the requirement.

Please feel free to write us back if you have any other query related to Aspose.Email.


It is some codes what I want to convert the attachment files.


AttachmentCollection ac = message.getAttachments();
for ( int i = 0; i < ac.size(); i++ ) {

Attachment attachment = (Attachment)ac.get(i);
System.out.println(“attachment, object=”+attachment.getName());
//InputStream is = attachment.getContentStream();
// How to append/insert this attached file (InputStream) to document?
}
document.save(strDocFile, SaveFormat.PDF);

Thanks,
Chang Shin

Hi Chang Shin,


As I have shared earlier, you need to refer to our other Aspose products once the attachments are downloaded using Aspose.Email for Java, because Aspose.Email doesn’t provide reading attachment files such as Excel, Word, Image, etc. Therefore, if an attachment is an Excel file, for example, you can contact the Aspose.Cells team to get information about if it can be converted/stored in a Word document or you may contact the Aspose.Words team to check the availability of an option for storing Excel file in a Word document using Aspose.Words.

Once you have all such info available, you can use Aspose.Email to download all the attachments and then convert each one to a single Word document for conversion to PDF. If you have any other query/inquiry related to Aspose.Email, please feel free to contact us. We’ll try to assist you further as soon as possible.


Thanks,

Chang Shin