GroupDocs.Conversion provides a flexible API to control the conversion of documents that contain other documents.
The following code snippet shows how to convert each attachment to a different format based on attachment type:
constfs=require('fs').promises;constemailLoadOptions=newgroupdocs.conversion.EmailLoadOptions();emailLoadOptions.setConvertOwned(true);emailLoadOptions.setConvertOwner(true);emailLoadOptions.setDepth(2);constconverter=newgroupdocs.conversion.Converter("sample_with_attachments.eml",emailLoadOptions);constconvertOptions=newgroupdocs.conversion.PdfConvertOptions();convertOptions.setPassword("12345");convertOptions.setDpi(300);constfileOutputStreams=[];try{awaitconverter.convert(async(t)=>{try{constfileOutputStream=awaitfs.open(`converted-${fileOutputStreams.length}.pdf`,'w');fileOutputStreams.push(fileOutputStream);returnfileOutputStream;}catch(e){thrownewError(e);}},options);}finally{try{for(constfileOutputStreamoffileOutputStreams){awaitfileOutputStream.close();}}catch(e){// throw an exception
}}
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.
Ask AI
Ask anything about this page — the answer is based on its content.
Searching the docs and writing an answer…
Something went wrong while getting an answer. Please try again in a moment.