99% of business documents used in our organisation are received via email and we have a requirement to pull these emails into our in house developed system that will be viewed in a browser. Currently we are making use of ABCPdf to convert an email and it's attachments to a single PDF file. We are experiencing problems with quality etc. Perhaps someone can recommend a C# library or software that can assist with the following requirements

  1. Convert email body and attachments to a single PDF or other web friendly file format
  2. Should be able to add a cover page to the PDF containing meta data
  3. The converted files should be of high quality and acceptable size that can be used to open in a browser

Alternatively we do not even have to convert any of the attachments and simply find a solution to open any file format within the browser.

We are using Windows OS and EWS to connect to the Outlook mailboxes. We currently have an in house written application that reads the emails, strips the attachments and do the conversions but do not mind paying if we can find a better commercial solution.


1 Answer 1


EML or MSG files can be converted to HTML using code available in this Code project article.

Syncfusion WebKit converter can be used to convert HTML to PDF.

// Code
string filePath = Path.GetFullPath("../../Data/MsgReaderContent.msg");
//Convert EML/MSG to HTML using third party reader
var msgReader = new Reader();
string tempFolder = GetTemporaryFolder();
//File contains the HTML file converted from MSG.
var files = msgReader.ExtractToFolder(filePath, tempFolder);
var error = msgReader.GetErrorMessage();
if (!string.IsNullOrEmpty(error))
throw new Exception(error);
//Converts the HTML to PDF using WebKit rendering engine.
if (!string.IsNullOrEmpty(files[0]))
//Initialize WebKit HTML with WebKit rendering engine.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings settings = new WebKitConverterSettings();
string WebKitBinaryPath ="../../QtBinaries/";
//WebKit assembly path
settings.WebKitPath = WebKitBinaryPath;
//Assign converter settings
htmlConverter.ConverterSettings = settings;
// Convert to PDF document.
PdfDocument document = htmlConverter.Convert(files[0]);
//Add cover page
PdfPage page = new PdfPage();
document.Pages.Insert(0, page);
PdfFont font = new PdfTrueTypeFont(new Font("Helvetica", 16, FontStyle.Bold), true);
PdfSolidBrush brush = new PdfSolidBrush(Color.FromArgb(44, 71, 120));
page.Graphics.DrawString("cover page",font,brush,new PointF());
//Insert attachments
for (int i = 1; i < files.Length; i++)
FileInfo file = new FileInfo(files[i]);
// Save and close the document.

private PdfAttachment AddAttachment(FileInfo f)
PdfAttachment attachment = new PdfAttachment(f.FullName);

attachment.ModificationDate = DateTime.Now;

attachment.Description = f.Name;
attachment.MimeType = "application/" + f.Extension;

//returns the attachment to the document

return attachment;

A complete sample application is also available here

The whole suite of controls and libraries is available for free through the community license program if you qualify (less than 1 million USD in revenue). Note: I work for Syncfusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.