发送邮件方法有问题
在这种方法中,我发送邮件
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猀搀搀昀ഀ 更多文本
和附加名称中的 hotmail,我得到了这个 牰敌慢瀮会议
。该方法有什么问题?
In this method i send mail
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);
And it works fine but in gmail in the body i got this text猀搀搀昀ഀ more text
and hotmail in attach name i got this 牰敵慢瀮晤
.What is wrong in the method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: