SMTP 客户端显示错误“未采取请求的操作”在 C# 应用程序中
我正在尝试使用 hotmail 帐户设置电子邮件发送应用程序。
代码如下所示:
MailMessage mail = new MailMessage(from, to);
mail.Subject = "Proba email";
mail.Attachments.Add(new Attachment("C:\\Documents and Settings\\Proba.txt"));
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Port = 587; // 465 568
client.Host = "smtp.live.com";
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
client.SendAsync(mail, "token");
使用异步,我实际上没有收到任何错误,我什至收到反馈说消息已发送(事件触发器),但消息从未到达。如果我使用简单的 client.Send void,我会收到以下错误:
5.3.4 未采取请求的行动;要继续发送消息,请登录您的帐户。
那么关于问题可能是什么的任何想法吗?当我试图传递 hotmail 的 SMTP 设置时,我得到了各种设置,说端口 25,然后是 587,所以也许是那里的东西。任何帮助将不胜感激,谢谢!
- 好的,现在肯定可以正常工作了,我只是想问一下,我是否必须定期进行“我不是机器人检查”,还是一次性的事情?
I am trying to setup an email sending application, using a hotmail account.
The code looks like this:
MailMessage mail = new MailMessage(from, to);
mail.Subject = "Proba email";
mail.Attachments.Add(new Attachment("C:\\Documents and Settings\\Proba.txt"));
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Port = 587; // 465 568
client.Host = "smtp.live.com";
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
client.SendAsync(mail, "token");
Using, Async I actually get no errors, I even get the feedback saying message sent (Event triggers) but the message never arrives. If I use the simple client.Send void, I get the following error:
5.3.4 Requested action not taken; To continue sending messages, please sign in to your account.
So any ideas on what the problem can be? As I was trying to hand down the SMTP settings of hotmail I got various setups saying port 25, then 587 so maybe it's something there. Any help would be greatly appreciated thanks!
- Okay so it's definitely working now, I would just like to ask if I will have to do regular "I'm not a robot checks" or was that a one-time thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我的设置,顺便说一句,异步不会返回任何错误。
Here is my setup, BTW async will not return any errors.
我有一个类似的设置,我只使用对我有用的 Send() 。我唯一额外的东西
就在
client.Send();
之前。不确定仅此是否可以解决您的问题。您是否使用相同的服务器和凭据设置了 Outlook?I have a similar setup where I just use Send() that is working for me. The only thing extra that I have is
just before
client.Send();
. Not sure if this alone will solve your problem. Do you have outlook setup with the same server and credentials ?