Convert an email file with attachments to PDF using C#
Atir Tahir
Posted on February 3, 2020
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.
💖 💪 🙅 🚩
Atir Tahir
Posted on February 3, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.