Skip to content

Convert an email file with attachments to PDF using C#

twitter logo ・1 min read  

There are a lot of document conversion APIs and they support Email to PDF conversion. But what about the Email (.eml or .msg) attachments?
Blow is the code to convert an Email file with attachments to PDF:

var source = "sample-with-attachment.eml";
var loadOptions = new EmailLoadOptions {ConvertAttachments = true};
using (var converter = new Converter(source, () => loadOptions))
    var index = 1;
    var options = new PdfConvertOptions();
    // Note: index = 1 is the email itself, all following indexes are attachments
    converter.Convert(() => new FileStream($"converted-{index++}.pdf", FileMode.Create) , options);

For further details see this post. You can also raise your concerns on forum.

twitter logo DISCUSS (1)
markdown guide : THE FASTEST PDF SDK FOR .NET APPLICATIONS Develop high performance .NET applications having the ability to Create, Edit, Convert, Protect or Print PDF documents, without requiring Adobe Acrobat. Must try this .

Classic DEV Post from Jul 17 '19

What are you (still) not interested in learning?

I'm interested in hearing not only what you are *not* interested in learning. But if you answered the question last time, has anything changed?

Atir Tahir profile image
Software developer and evangelist.

Hey there reader...

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️