We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Embedded image not being captured

Hi all,

I’m currently trying to save an email message to pdf, here is my code;

string sharedDrivePathWithPDFName = string.Empty;
// Load email message
//ErrorLogging(“0 Email Body-” + message.Body.ToString());
MemoryStream emailStream = new MemoryStream();

            message.Save(emailStream, MailMessageSaveType.MHtmlFromat);

            ErrorLogging("Email pdf conversion - LoadOptions - Aspose.Words.LoadOptions start");
            //Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions(Aspose.Words.LoadFormat.Html, null, null);
            Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions(LoadFormat.MHtml, null, null);

            ErrorLogging("Email pdf conversion - LoadOptions End");

            Aspose.Words.Document document = new Aspose.Words.Document(emailStream, loadOptions);

            ErrorLogging("Page formatting Started");
            DocumentBuilder builder = new DocumentBuilder(document);
            builder.PageSetup.Orientation = Orientation.Landscape;
            builder.PageSetup.PaperSize = PaperSize.Ledger;
            builder.PageSetup.VerticalAlignment = PageVerticalAlignment.Center;
            builder.PageSetup.LeftMargin = ConvertUtil.MillimeterToPoint(10);
            builder.PageSetup.RightMargin = ConvertUtil.MillimeterToPoint(10);
            builder.PageSetup.TopMargin = ConvertUtil.MillimeterToPoint(5);
            builder.PageSetup.BottomMargin = ConvertUtil.MillimeterToPoint(15);
            builder.PageSetup.Borders.LineStyle = LineStyle.Single;
            builder.PageSetup.HeaderDistance = ConvertUtil.MillimeterToPoint(12.5);
            builder.PageSetup.FooterDistance = ConvertUtil.MillimeterToPoint(12.5);

            ErrorLogging("Page formatting Ended");
            PdfSharePath = Regex.Replace(PdfSharePath, @"^\s+$[\r\n]*", @"\r\n", RegexOptions.None);

            ErrorLogging("PDF Share Path "+ PdfSharePath.ToString());
            sharedDrivePathWithPDFName = PdfSharePath + recordId;
            ErrorLogging("Email pdf save to path start");
            document.Save(PdfSharePath + recordId +".pdf", Aspose.Words.SaveFormat.Pdf);
            ErrorLogging("Email pdf complete");
        catch (Exception ex)
        return sharedDrivePathWithPDFName + ".pdf";

the email contains an embedded logo which is being lost during the conversion, how can I ensure the logo is captured along with the message body?


Could you please ZIP and attach your message file and problematic PDF here for testing? We will investigate the issue and provide you more information on it.