在这种方法中我发送邮件
var mail = new MailMessage();
mail.Subject = subject;
mail.SubjectEncoding = Encoding.UTF8;
mail.IsBodyHtml = mailServer.EsHtml;
mail.From = new MailAddress(mailFrom, nomFrom,Encoding.UTF8);
foreach(var item in mailTo)
mail.To.Add(new MailAddress(item.Key, item.Value, Encoding.UTF8));
foreach(var item in mailCC)
mail.Bcc.Add(new MailAddress(item.Key, item.Value, Encoding.UTF8));
mail.Body = message;
mail.BodyEncoding = Encoding.Unicode;
mail.Attachments.Add(new Attachment(attachments));
var clientMail = new SmtpClient();
clientMail.Credentials = new System.Net.NetworkCredential(mailFrom, passMail);
if(mailServer.PuertoCorreo.HasValue)
clientMail.Port = mailServer.PuertoCorreo.Value;
clientMail.Host = mailServer.ServidorCorreo;
clientMail.EnableSsl = mailServer.HabilitarSSL;
clientMail.Send(mail);
它工作正常,但在身体的gmail中,我得到了这个text猀搀搀昀ഀ more text
和附加名称的hotmail我得到了这个牰敵慢瀮晤
。方法有什么问题?
答案 0 :(得分:0)
试试这个:
mail.BodyEncoding = System.Text.Encoding.UTF8;