当我经常向用户列表发送一些电子邮件时,我收到此错误。假设它发送了 10 封邮件,其中 1 封给出了错误,然后再发送了几封邮件并给出了相同的错误。
代码如下所示:
public static bool SendEmail(string toMail, string fromname, string from, string subject, string body, string BCC)
{
MailMessage mailmessage = new MailMessage("frommail@mail.com", 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:服务不可用,正在关闭传输通道。服务器响应为:4.4.2 mailer.mailer.com 错误:System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[ ] 命令,字符串来自)在 System.Net.Mail.SmtpTransport.SendMail(MailAddress 发件人,MailAddressCollection 收件人,字符串 deliveryNotify,SmtpFailedRecipientException& 异常)在 System.Net.Mail.SmtpClient.Send(MailMessage 消息)
任何人都可以请帮助,这个错误正在杀死我。
提前致谢。