HtmlToPdfConvert Method (String, String) |
Namespace: MailBee.Pdf
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | source or pdfFile is a null reference (Nothing in Visual Basic) or an empty string. |
MailBeeStreamException | A stream error occurred. |
MailBeeIOException | An I/O error occurred. |
If SourceType is Html (default value), the input is considered HTML; if SourceType is Text the input is considered plain-text; otherwise, XMLized XHTML.
If your source is BodyHtmlText and the message contains embedded pictures, you need to save them first (like in the example below).
using System; using System.IO; using MailBee; using MailBee.Mime; using MailBee.Pdf; using MailBee.SmtpMail; class Sample { static void Main(string[] args) { MailMessage msg = new MailMessage(); msg.LoadMessage(@"C:\Temp\source.eml"); HtmlToPdf htmlConv = new HtmlToPdf(); msg.Parser.WorkingFolder = Path.GetTempPath(); try { string htmlWithRealImgLinks = msg.GetHtmlAndSaveRelatedFiles(null, VirtualMappingType.NonWeb, MessageFolderBehavior.CreateAndDelete); htmlConv.Convert(htmlWithRealImgLinks, @"C:\Temp\result.pdf"); } finally { msg.Dispose(); } } }