使用{System.Net.Mail.SmtpException发送邮件失败:身份验证失败.} [英] Sending Mail Failure using {System.Net.Mail.SmtpException: Authentication failed.}
本文介绍了使用{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.com";
client.Port = 25;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("username@xx.com", "pwd");
client.UseDefaultCredentials = false;
client.Credentials = credentials;
msg.From = new MailAddress("ams@xx.com",System.Text.Encoding.UTF8);
msg.To.Add(xx@gmail.com);
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.com");
message.To.Add(new MailAddress("ngqandu.anele@gmail.com"));
message.Subject = subject.Text;
message.Body = body.Text;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential ("userid@yahoo.com", "password");
client.Port = 587;
client.Host = "smtp.mail.yahoo.com";
client.EnableSsl = false;
try
{
client.Send(message);
}
catch (Exception ex)
{
MessageBox.Show
(ex.Message,"Information",MessageBoxButton.OK,MessageBoxImage.Information);
}
这篇关于使用{System.Net.Mail.SmtpException发送邮件失败:身份验证失败.}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文