當我經常向用戶列表發送一些電子郵件時,出現此錯誤。假設它發送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