使用System.Net.Mail发送纯文本电子邮件时如何设置传输编码

时间:2012-05-29 23:53:42

标签: .net smtp smtpclient

当我使用SmtpClient类发送纯文本电子邮件时,传输编码设置为quoted-printable:

Content-Transfer-Encoding: quoted-printable

如何更改?

1 个答案:

答案 0 :(得分:2)

使用AlternateView撰写邮件:

 MailMessage message = new MailMessage("from@example.com", "to@example.com");
 message.Subject = "Test";
 AlternateView plainText = AlternateView.CreateAlternateViewFromString("test");
 plainText.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
 message.AlternateViews.Add(plainText);
 message.IsBodyHtml = false;

 SmtpClient smtp = new SmtpClient();
 smtp.Send(message);