GroupDocs.Conversion provides the EmailLoadOptions class to give you better control over how the source email document will be processed. The following options could be set:
setFormat** allows you to specify explicitly the type of the source email document. Available options are: Msg, Eml, Emlx, Pst, Ost, Vcf, Mht.
setDisplayHeader specifies option to display or hide the email header.
The following code snippet shows how to convert an Email document and all attachments:
importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.contracts.SaveDocumentStreamForFileType;importcom.groupdocs.conversion.options.convert.PdfConvertOptions;importcom.groupdocs.conversion.options.load.EmailLoadOptions;importjava.io.IOException;importjava.io.OutputStream;importjava.nio.file.Files;importjava.nio.file.Paths;importjava.util.ArrayList;importjava.util.List;...EmailLoadOptionsemailLoadOptions=newEmailLoadOptions();emailLoadOptions.setConvertOwned(true);emailLoadOptions.setConvertOwner(true);emailLoadOptions.setDepth(2);Converterconverter=newConverter("sample_with_attachments.eml",emailLoadOptions);finalList<FileOutputStream>fileOutputStreams=newArrayList<>();try{converter.convert(newSaveDocumentStreamForFileType(){@OverridepublicStreaminvoke(FileTypet){try{FileOutputStreamfileOutputStream=newFileOutputStream("converted-"+fileOutputStreams.size()+".pdf");fileOutputStreams.add(fileOutputStream);returnnewGroupDocsOutputStream(fileOutputStream);}catch(IOExceptione){thrownewRuntimeException(e);}}},newPdfConvertOptions());}finally{try{for(OutputStreamoutputStream:fileOutputStreams){outputStream.close();}}catch(IOExceptione){//throw an exception
}}
Warning
This functionality is introduced in v21.7
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.