We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert EML or MSG to PDF with Attachment and cover page?

How to convert EML or MSG to PDF with Attachment and cover page?

We can convert EML or MSG to PDF with attachments and also we can add cover page to the PDF. The EML or MSG files can be converted to HTML using the code project sample available in the below link, then Syncfusion WebKit converter can be used to convert HTML to PDF, please find the sample and code snippet below,



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;



Code Project Link:


Sample Link:


Note: You can get QtBinaries and Syncfusion wrapper by installing WebKit HTML converter.

Latest WebKit HTML converter: https://www.syncfusion.com/downloads/latest-version

Article ID: Published Date: Last Revised Date: Platform: Control:
7312 01/27/2017 01/27/2017 WinForms PDF
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon