我如何通过电子邮件发送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到HTML转换

问题是仍然不能保存格式。 看起来他的FlowDocumentToXhtml不包含文本对齐的值。

任何其他想法?

链接地址: http://www.djcxy.com/p/61133.html

上一篇: How do I email a FlowDocument and retain its formatting

下一篇: Getting selected text from a RichTextBox only on MouseUp?