当我经常向用户列表发送一些电子邮件时,出现此错误。假设它发送10封邮件,1发出错误,然后发送更多邮件并给出相同的错误。System.Net.Mail.SmtpException:服务不可用,关闭传输通道。服务器响应是:4.4.2
的代码看起来是这样的:
public static bool SendEmail(string toMail, string fromname, string from, string subject, string body, string BCC)
{
MailMessage mailmessage = new MailMessage("[email protected]", toMail, subject, body);
mailmessage.IsBodyHtml = true;
mailmessage.BodyEncoding = Encoding.GetEncoding(1254);
mailmessage.SubjectEncoding = Encoding.GetEncoding(1254);
SmtpClient objCompose = new SmtpClient("xxxx");
try
{
objCompose.Send(mailmessage);
return true;
}
catch (Exception ex) {
}
return false;
}
而我得到的错误是这样的:
System.Net.Mail.SmtpException: Service not available, closing transmission channel. The server response was: 4.4.2 mailer.mailer.com Error: timeout exceeded at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message)
任何人都可以请大家帮忙,这个错误是我的命。
在此先感谢。
MailMessage.Dispose()(.NET 3.5) – garik 2012-06-06 13:36:43
没有为我工作。那么......它摆脱了这个例外,但现在它只是在发送一两封电子邮件时挂起。 – 2012-11-30 04:41:21