我在下面有一些代码
try {
SmtpClient SmtpServer = new SmtpClient();
string sBody = null;
sBody = "body content";
var _with1 = SmtpServer;
_with1.Credentials = new System.Net.NetworkCredential("abc@gmail.com", "abc");
_with1.Host = "smtp.gmail.com";
_with1.EnableSsl = true;
using (MailMessage mail = new MailMessage()) {
//mail = New MailMessage()
var _with2 = mail;
_with2.From = new MailAddress("abc@gmail.com");
_with2.To.Add("cdf@yahoo.com.vn");
_with2.Subject = "Thông báo có góp ý cho câu hỏi";
_with2.Body = sBody;
_with2.IsBodyHtml = true;
SmtpServer.Send(mail);
}
} catch (Exception) {
throw;
}
它在窗口 7 上运行良好
但是当我在窗口服务器 2003 上运行它时,它有一个错误:“SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1 需要身份验证。了解更多信息”
请帮我修复它!
谢谢