我有一个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
似乎不包含文本对齐的值。
还有其他想法吗?