本文介绍了发送Mail Asp.Net时出现“身份验证失败”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 即使搜索了很多网站后仍未找到答案 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([email protected],password); smtp .DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; MailMessage msg = new MailMessage(); msg.From = new MailAddress(abc @ myorganization。 COM); msg.To.Add(新邮件地址([email protected])); 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.Send(MailMessage消息) at在解决方案 中的MailConfiguration.TestMail()在设置之前将UseDefaultCredentials设置为false证书属性 https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials(v = vs.110)的.aspx [ ^ ] No answer found even after searching many sitesi 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("[email protected]", "password"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; MailMessage msg = new MailMessage(); msg.From = new MailAddress("[email protected]"); msg.To.Add(new MailAddress("[email protected]")); msg.Subject = "Test"; msg.Body = "Test mail"; smtp.Timeout = 60000; smtp.Send(msg); result = true; } catch (Exception ex) { }My exception error isSystem.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 propertyhttps://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials(v=vs.110).aspx[^] 这篇关于发送Mail Asp.Net时出现“身份验证失败”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 21:31