I’m trying to convert an email to a word document, and I’m encountering the problem that the background of the email is not included in the document.
I’m using the following code:
// the MailMessage class is part of Aspose.Network
private Document GetDocumentFromEmail(MailMessage mailMessage)
{
// create the Word Document
Document document = new Document();
// create the Word DocumentBuilder
DocumentBuilder documentBuilder = new DocumentBuilder(document);
// set the papersize to A4
documentBuilder.PageSetup.PaperSize = PaperSize.A4;
if (mailMessage.IsBodyHtml && !string.IsNullOrEmpty(mailMessage.HtmlBody))
{
documentBuilder.InsertHtml(mailMessage.HtmlBody);
}
else
{
documentBuilder.Write(mailMessage.TextBody);
}
return document;
}
Can someone please tell me what I’m doing wrong?
Attached is a test email file.
Hello
Thanks for your request. If you try to save _message.HtmlBody as separate HTML file and open this HTML document using any browser, you will see, there is no any background. After inserting this HTML inside a Document, you will see the same result.
Best regards,
Hello
Thanks for your request. If you have an ability to get this background using Aspose.Network then you will be able to set this background using BackgroundShape property of Aspose.Words document object. Please see the following link: https://reference.aspose.com/words/net/aspose.words/documentbase/backgroundshape/
Best regards,