Nnp*_*Nnp 13 .net c# smtpclient
这是我的代码
for(int i = 0; i < number ; i++)
{
MailAddress to = new MailAddress(iMail.to);
MailAddress from = new MailAddress(iMail.from, iMail.displayName);
string body = iMail.body;
string subject = iMail.sub;
oMail = new MailMessage(from, to);
oMail.Subject = subject;
oMail.Body = body;
oMail.IsBodyHtml = true;
oMail.Priority = MailPriority.Normal;
oMail.Sender = from;
s = new SmtpClient(smtpServer);
if (s != null)
{
s.Send(oMail);
}
oMail.Dispose();
s = null;
}
Run Code Online (Sandbox Code Playgroud)
这个循环发送超过60,000封电子邮件.但是我的问题是我在一些电子邮件中发送"发送邮件失败"了5000次,而且剩下的时间少了一些时间.我检查了所有那些错误,电子邮件有有效的电子邮件地址.不知道是什么问题.我真的需要帮助.
编辑:这是我的异常跟踪
错误 - 发送邮件失败.Inner Ex - System.IO.IOException:无法从传输连接中读取数据:net_io_connectionclosed.在System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(字节[]缓冲液,的Int32偏移的Int32读,布尔的readLine)在System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader呼叫者,布尔ONELINE)在System.Net.Mail.SmtpReplyReaderFactory .ReadLine(SmtpReplyReader呼叫者)在System.Net.Mail.CheckCommand.Send在System.Net在System.Net.Mail.MailCommand.Send(SmtpConnection康恩,字符串&响应)(康涅狄格州SmtpConnection,字节[]命令,从字符串). Mail.SmtpTransport.SendMail(MailAddress sender,MailAddressCollection recipients,String deliveryNotify,SmtpFailedRecipientException&exception)
好吧,"发送电子邮件失败"应该有更多的细节.但是有一些事情可能导致这种情况.
无论是其中一个还是其他错误,您都需要查看异常和内部异常以获得更多细节.
| 归档时间: |
|
| 查看次数: |
92487 次 |
| 最近记录: |