我正在通过创建邮件正文
using (var streamWriter = new StreamWriter(fooFileName, false, Encoding.UTF8))
{
streamWriter.Write(fooMessage);
}
现在我用这个文件
var mailMessage = new System.Net.Mail.MailMessage
{
From = fooSender,
To =
{
fooRecipient
},
Subject = fooSubject,
SubjectEncoding = Encoding.UTF8,
BodyEncoding = Encoding.UTF8
};
// fooMediaType can be
// - System.Net.Mime.MediaTypeNames.Text.Html
// - System.Net.Mime.MediaTypeNames.Text.Plain
var alternateView = new System.Net.Mail.AlternateView(fooFileName, fooMediaType);
mailMessage.AlternateViews.Add(alternateView);
如果我使用的是非umlauts,一切正常,但只要我在我的
alternateView
,它们会破碎。
那么,如何在AlternateView上设置某种编码,以确保一切正常工作?