@agilelaw
Yes, it is possible. The key point is to use Convert()
method with ConvertOptionsProvider
overload. It is called for each converted document (the MSG itself and for each attachment). By this you can set different ConvertOptions
depending on the document type to be converted. Here is a sample code snippet:
var index = 1;
GroupDocs.Conversion.Options.Load.LoadOptions LoadOptionsProvider(FileType sourceType)
{
if (sourceType == EmailFileType.Eml)
{
return new GroupDocs.Conversion.Options.Load.EmailLoadOptions
{
ConvertOwned = true,
ConvertOwner = true,
Depth = 2
};
}
return null;
}
Stream ConvertedStreamProvider(FileType targetType)
{
string outputFile = $"converted-{index++}.{targetType.Extension}";
return new FileStream(outputFile, FileMode.Create);
}
ConvertOptions ConvertOptionsProvider(string sourceDocumentName, FileType sourceType)
{
if (sourceType == EmailFileType.Eml)
{
return new PdfConvertOptions();
}
if (sourceType == WordProcessingFileType.Docx)
{
return new WordProcessingConvertOptions();
}
return new ImageConvertOptions();
}
using (var converter = new Converter("sample_with_attachments.eml", LoadOptionsProvider))
{
converter.Convert(ConvertedStreamProvider, ConvertOptionsProvider);
}