2011-07-07 68 views
0

在這種方法我發送郵件問題發送郵件法

 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); 

,它工作正常,但在身體,我得到這個text਍猀攙攙昀ഀ more text和Hotmail的Gmail附上名字我得到這個牰敵慢瀮晤。什麼是錯的方法?

+1

什麼是預期的結果,你應該有嗎?哪個文本就是你把電子郵件的正文? –

+0

你確定你正在使用的編碼,你確定你可以將它們混合在同一封電子郵件中嗎? –

+0

我用richtextbox控制文本和日本人之間的身體字符輸入和日期字符和更多的文本之間輸入和選項卡 – elchente23

回答

0

試試這個:

mail.BodyEncoding = System.Text.Encoding.UTF8;