使用{System.Net.Mail.SmtpException发送邮件失败:身份验证失败.}

编程入门 行业动态 更新时间:2024-10-18 12:19:06
本文介绍了使用{System.Net.Mail.SmtpException发送邮件失败:身份验证失败.}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

伙计们 我正在使用

HI guys I am using

System.Net.Mail;

在Windows应用程序中发送邮件. 我所有的凭据都正确,但是我收到身份验证失败"错误消息.. 我已经尝试了很多,但是没有奏效.有人可以帮我吗 这是我正在深入了解的错误消息...

to send mails in windows application . all my credentials are right but i am getting "Authentication failed" Error message.. I have tried a lot but it didn''t worked .. Can anyone Help me pls this is the error message i am getting in depth...

<br /> {System.Net.Mail.SmtpException: Authentication failed.<br /> at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)<br /> at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)<br /> at System.Net.Mail.SmtpClient.GetConnection()<br /> at System.Net.Mail.SmtpClient.Send(MailMessage message)

这是代码:

here is the code:

SmtpClient client = new SmtpClient(); MailMessage msg = new MailMessage(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = false; client.Host = "mail.xx"; client.Port = 25; System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("username@xx", "pwd"); client.UseDefaultCredentials = false; client.Credentials = credentials; msg.From = new MailAddress("ams@xx",System.Text.Encoding.UTF8); msg.To.Add(xx@gmail); msg.Subject = Subject; msg.SubjectEncoding = System.Text.Encoding.UTF8; msg.Priority = MailPriority.High; msg.Body = Body; msg.BodyEncoding = System.Text.Encoding.UTF8; msg.IsBodyHtml = true; msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(msg);

在此先谢谢 添加了代码块[/编辑]

Thanks In advance Code block added[/Edit]

推荐答案

如果没有您的代码来检查您的工作方式,我们将无济于事. 但是,这可行:使用C#发送带有或的电子邮件不带附件:通用例程. [ ^ ],因此可能值得检查一下如何做到这一点. Without your code to check how you are doing it, we can''t rally help much. However, this works: Sending an Email in C# with or without attachments: generic routine.[^] so it might be worth checking how you do it against that.

您好, Hi MailMessage message = new MailMessage(); message.From = new MailAddress("userid@yahoo"); message.To.Add(new MailAddress("ngqandu.anele@gmail")); message.Subject = subject.Text; message.Body = body.Text; SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential ("userid@yahoo", "password"); client.Port = 587; client.Host = "smtp.mail.yahoo"; client.EnableSsl = false; try { client.Send(message); } catch (Exception ex) { MessageBox.Show (ex.Message,"Information",MessageBoxButton.OK,MessageBoxImage.Information); }

更多推荐

使用{System.Net.Mail.SmtpException发送邮件失败:身份验证失败.}

本文发布于:2023-11-17 12:22:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609991.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送邮件   身份验证   Net   System   SmtpException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!