GroupDocs.Conversion provides the EmailLoadOptions class to give you control over how the source email document will be processed. The following options could be set:
The document type is auto-detected during loading, however, you can specify explicitly the type of the source email document. Available options are: Msg, Eml, Emlx, Pst, Ost, Vcf, Mht
Controls whether the documents container itself must be converted If this property is true the documents container will be the first converted document
Gets or sets the Coordinated Universal Time (UTC) offset for the message dates. This property defines the time zone difference, between the local time and UTC.
Control fields visibility
The following code snippet shows how to convert an Email document and control the visibility of the fields:
The following code snippet shows how to convert an Email document and all attachments:
With v24.10 and later:
varsource="sample-with-attachment.eml";varloadOptions=newEmailLoadOptions{ConvertOwner=true,ConvertOwned=true,// convert email itself and the attachmentsDepth=2};using(varconverter=newConverter(source,(LoadContextloadContext)=>loadOptions)){varindex=1;varoptions=newPdfConvertOptions();// Note: index = 1 is the email itself, all following indexes are attachmentsconverter.Convert((SaveContextsaveContext)=>newFileStream($"converted-{index++}.{saveContext.TargetFormat.Extension}",FileMode.Create),options);}
Before v24.10:
varsource="sample-with-attachment.eml";varloadOptions=newEmailLoadOptions{ConvertOwner=true,ConvertOwned=true,// convert email itself and the attachmentsDepth=2};using(varconverter=newConverter(source,()=>loadOptions)){varindex=1;varoptions=newPdfConvertOptions();// Note: index = 1 is the email itself, all following indexes are attachmentsconverter.Convert(()=>newFileStream($"converted-{index++}.pdf",FileMode.Create),options);}
Localize email fields captions
The following code snippet shows how to convert an Email document and localize the Email fields: