Hi all,
I’m currently trying to save an email message to pdf, here is my code;
string sharedDrivePathWithPDFName = string.Empty;
// Load email message
try
{
//ErrorLogging(“0 Email Body-” + message.Body.ToString());
MemoryStream emailStream = new MemoryStream();
message.Save(emailStream, MailMessageSaveType.MHtmlFromat);
//message.Save(emailStream);
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");
emailStream.Flush();
emailStream.Dispose();
}
catch (Exception ex)
{
ErrorLogging(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?