【发布时间】:2016-01-09 15:12:14
【问题描述】:
搜索了很多网站也没有找到答案
我正在使用 VS2010(Framework 4.0) 和 SQL 2012,我们正在使用 Exchange 服务器....相同的邮件配置在 java 应用程序中工作,但在 c# 中不工作
按钮点击代码是:
try
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.myorganization.com"
smtp.Port = "587";
smtp.Credentials = new System.Net.NetworkCredential("abc@myorganization.com", "password");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.From = new MailAddress("abc@myorganization.com");
msg.To.Add(new MailAddress("receiver@something.com"));
msg.Subject = "Test";
msg.Body = "Test mail";
smtp.Timeout = 60000;
smtp.Send(msg);
result = true;
}
catch (Exception ex)
{
}
我的异常错误是
System.Net.Mail.SmtpException was caught
HResult=-2146233088
Message=Authentication failed.
Source=System
StackTrace:
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at MailConfiguration.TestMail() in
【问题讨论】:
-
可以telnet mail.myorganization.com 587看看结果如何
-
你能建议怎么做吗? @Shetty
-
在命令提示符下键入“telnet mail.myorganization.com 587”。使用正确的服务器名称
-
我做了,它说 -- 'telnet' 不是被识别为内部或外部命令、可运行程序或批处理文件
-
控制面板>程序>打开或关闭 Windows 功能。然后,检查“Telnet 客户端”并保存更改。您可能需要等待大约几分钟才能使更改生效。