SmtpClinet.SendAsync异步发送邮件

尘世奇葩 2016-04-25 02:54:38
SmtpClinet.SendAsync异步发送邮件,调试的时候能收到,非调试的时候却收不到,这个可能是什么原因造成的,各位大神谁便给点建议
...全文
228 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Poopaye 2016-04-25
  • 打赏
  • 举报
回复
估计调试的时候发过头了,后面的邮件全被拒绝掉了
阿修拉姆 2016-04-25
  • 打赏
  • 举报
回复
确定你的服务器能连上smtp服务器嘛?
尘世奇葩 2016-04-25
  • 打赏
  • 举报
回复
//异步发送 mSmtpClient.SendCompleted += new SendCompletedEventHandler(smtp_SendCompleted); try { mSmtpClient.SendAsync(mMailMessage, null); } catch (Exception ex) { WriteLogFile(@"C:\Users\Administrator\Desktop\testlog", ex.Message); } // 回调函数 void smtp_SendCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) //邮件发送被取消 { WriteLogFile(@"C:\Users\Administrator\Desktop\testlog", "sendCanceledtest"); } if (e.Error != null) //邮件发送失败 { WriteLogFile(@"C:\Users\Administrator\Desktop\testlog", "senderrortest" + e.Error.ToString()); } else //发送成功 { WriteLogFile(@"C:\Users\Administrator\Desktop\testlog", "sendsuccesstest"); } }
q107770540 2016-04-25
  • 打赏
  • 举报
回复
写log 排错
尘世奇葩 2016-04-25
  • 打赏
  • 举报
回复
引用 1 楼 q107770540 的回复:
写log 排错
写了Log,确定是发送成功,但就是没有收到。回调函数里也表示发送成功

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧