发送Mail Asp.Net时出现“身份验证失败”错误 [英] “Authentication failed” error in sending Mail Asp.Net
问题描述
即使搜索了很多网站后仍未找到答案
i我正在使用VS2010(Frame work 4.0)和SQL 2012,我们正在使用交换服务器....同样的邮件配置是在java应用程序中工作但不能在c#
按钮点击代码是:
试试
{
SmtpClient smtp =新的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(新邮件地址(receiver@something.com));
msg.Subject =测试;
msg.Body =测试邮件;
smtp.Timeout = 60000;
smtp.Send(msg);
result = true;
}
catch(例外情况)
{
}
我的异常错误是
System.Net.Mail.SmtpException被捕获
HResult = -2146233088
消息=身份验证失败。
来源=系统
StackTrace:
在System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
在System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)< System.Net.Mail.SmtpClient.GetConnection()的
在System.Net.Mail.SmtpClient.Send(MailMessage消息)
at在
中的MailConfiguration.TestMail()在设置之前将UseDefaultCredentials设置为false证书属性
https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials(v = vs.110)的.aspx [<一个href =https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ]
No answer found even after searching many sites
i am using VS2010(Frame work 4.0) and SQL 2012 , we are using exchange server....same mail configuration is working in java application but not working in c#
button click code is :
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)
{
}
My exception error is
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
Set UseDefaultCredentials to false before you set the Credentials property
https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials(v=vs.110).aspx[^]
这篇关于发送Mail Asp.Net时出现“身份验证失败”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!