如何通过电子邮件发送FlowDocument并保留其格式

时间:2015-04-09 15:35:47

标签: c# wpf flowdocument

我有一个FlowDocument我需要在WPF中发送电子邮件。问题是格式化现在正常工作。想通过这种方式做到这一点很简单;

var fromAddress = new MailAddress("myemail@emailaddress.com", fromID);
var toAddress = new MailAddress(emailAddress, toID);
string boby = new TextRange(doc.ContentStart, doc.ContentEnd).Text;
string subject = "My email";
const string fromPassword = "mypassword"
var smtp = new SmtpClient
{
    Host = "smtp.gmail.com",
    Port = 587,
    EnableSsl = true,
    DeliveryMethod = SmtpDeliveryMethod.Network,
    UseDefaultCredentials = false,

    Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
    Subject = subject,
    Body = body,
})
{
    smtp.Send(message);
}

虽然这有效但问题是它不会保留FlowDocument doc

的格式

修改 根据我在这里举例说明的评论;
C# FlowDocument to HTML conversion

问题仍然是不能保留格式。他的FlowDocumentToXhtml似乎不包含文本对齐的值。

还有其他想法吗?

0 个答案:

没有答案