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
Whether to convert an EML, EMLX or MSG message and its attachments into a single paginated PDF, with a bookmark for each part. Only PDF is supported as the target format. Default: false. Available since version 26.11. See Merge an email and its attachments into one PDF.
A handler called for each resource the message asks to load; it can allow the resource, skip it or supply its content. Default: null. Available since version 26.10.
Whether to skip the external resources the message references, such as remote images. Default: true. Content the message carries, local files inside its folder and resources that match WhitelistedResources still load. See Skip loading of external resources.
Absolute URI prefixes, such as https://cdn.example.com/assets/, of external resources to load while SkipExternalResources is true. Since version 26.10, an entry that is not an absolute URI prefix makes the load fail with InvalidLoadOptionsException.
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:
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);}
Merge an email and its attachments into one PDF
Since version 26.11, the MergeAttachments option converts an EML, EMLX or MSG message and its attachments into a single paginated PDF instead of one file per item. The option is off by default.
The following code snippet shows how to convert an email and its attachments into one PDF: