SmtpClient charset麻烦

时间:2015-11-26 08:35:01

标签: c# character-encoding mono smtpclient

我有代码将邮件发送到目的电子邮件。当我从Windows运行程序 - charset正常工作。但是当我在Linux VDS(Centos)中运行此应用程序时,charset不正确 - 例如 。关于西里尔文的消息。我尝试制作charset utf-8,但它也无法正常工作

SmtpClient smtp = new SmtpClient(Smtp, Convert.ToInt32(port));
smtp.Credentials = new NetworkCredential(login, pass);
smtp.EnableSsl = true;
MailMessage message = new MailMessage();
message.From = new MailAddress(from);
message.To.Add(new MailAddress(to));
message.IsBodyHtml = true;
message.Subject = subject;
message.Body = string.Format(msg);
message.BodyEncoding = Encoding.UTF8;
Console.WriteLine(msg);
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };

smtp.Send(message)

0 个答案:

没有答案