在.Net 2.0中通过需要Smtp验证的服务器发送邮件。 09/20/2006 06:24:29 PM Views: 155 Pictures: 0 做vip.pspper.com的密码找回,又碰到了邮件发送失败的问题。 以前没去管,直接用1.1的方式了。这次总算知道怎么解决了。 两个解决方案 一、Web.Config配置法 < system .net > < mailSettings > < smtp from ="support@pspper.com" > < network host ="mail.lukiya.com" password ="111111111" userName ="support@pspper.com" defaultCredentials ="false" /> </ smtp > </ mailSettings > </ system.net > 二、编码 红色是重点。 MailMessage m = new MailMessage("*****@163.com", ToEmail); m.Body = content; m.Subject = "title"; m.SubjectEncoding = ASCIIEncoding.GetEncoding("gb2312"); m.BodyEncoding = ASCIIEncoding.GetEncoding("gb2312"); m.IsBodyHtml = true; SmtpClient k = new SmtpClient("smtp.163.com"); k.Credentials.GetCredential("smtp.163.com", 25, "Network"); NetworkCredential nc = new NetworkCredential("*****@163.com", "12345"); k.Credentials = nc; k.Send(m);