![]() ![]() Var embeddedSrc = $"data:" įor more information (like how to add email headers and attachments to output PDF), check the Convert Email to PDF examples. "data:image/png base64,AABBCC."ĬontentEntity entity = attachment.MimeEntity ![]() Var imageId = ("cid:", "") Īttachment attachment = attachments.FirstOrDefault(a => a.ContentId = imageId) Iterate through the "src" attributes from HTML images in reverse order.įoreach (var match in Regex.Matches(htmlBody, srcPattern, RegexOptions.IgnoreCase).Cast().Reverse()) Static string ReplaceEmbeddedImages(string htmlBody, AttachmentCollection attachments) Var rtfBody = (()) ĭ(rtfBody, rtfOptions) ĭ(message.BodyText, LoadOptions.TxtDefault) Var rtfAttachment = (a => a.FileName = "Body.rtf") Var htmlBody = ReplaceEmbeddedImages(message.BodyHtml, message.Attachments) ĭ(htmlBody, htmlOptions) Įlse if ((a => a.FileName = "Body.rtf")) Replace attached CID images to inlined DATA urls. Var htmlOptions = LoadOptions.HtmlDefault If (!string.IsNullOrEmpty(message.BodyHtml)) Static void LoadBody(MailMessage message, DocumentModel document) PST export type then move to select the messages or folder. ![]() Import the email's body to the document. In Outlook 2016 for Windows it’s at File Open and Export Import / Export then choose Export to a file. MailMessage message = MailMessage.Load("input.msg") ĭocumentModel document = new DocumentModel() Load an email (or retrieve it with POP or IMAP). Nevertheless, you can retrieve it as an Attachment named " Body.rtf".Īlso as an FYI, another problem you have is that the images from the email's HTML body are not inlined, and thus, you'll lose them when exporting to PDF.Īnyway, try using the following: static void Main() The MailMessage class currently doesn't expose API for the RTF body (only plain and HTML body). The problem occurs with specific MSG files that don't have HTML content within an RTF body, instead, they have raw RTF body. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |