Viene visualizzato questo errore quando invio frequentemente alcuni messaggi di posta elettronica a un elenco di utenti. Diciamo che manda 10 mail e 1 dà un errore, quindi invia un altro paio di mail e dà lo stesso errore.System.Net.Mail.SmtpException: servizio non disponibile, chiusura del canale di trasmissione. La risposta del server è stata: 4.4.2
Il codice simile a questo:
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;
}
E l'errore che ottengo è questo:
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)
Qualcuno può aiutare, questo bug mi sta uccidendo.
Grazie in anticipo.
MailMessage.Dispose() (.NET 3.5) – garik
non ha funzionato per me. Bene ... si è sbarazzato dell'eccezione, ma ora si blocca solo quando si invia un'email o due. Errore –