0
我使用這個代碼來發送電子郵件:SmtpFailedRecipientsException的所有電子郵件地址,我測試
MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient(_smtpServer, _smtpPort);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(_smtpUser, _smtpPassword);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = _smtpSSL;
mail.From = new MailAddress(_fromEmail);
mail.To.Add(new MailAddress(toEmail, toName));
if (!String.IsNullOrEmpty(ccEmail))
mail.CC.Add(new MailAddress(ccEmail, ccName));
mail.Subject = subject;
mail.Body = body;
mail.Priority = MailPriority.High;
if (attachment != null)
{
if (String.IsNullOrEmpty(fileName))
fileName = "Adjunto " + DateTime.Today.ToString("yyyyMMddHHmmss" + ".pdf");
mail.Attachments.Add(new Attachment(attachment, fileName, "application/pdf"));
}
smtp.Send(mail);
return true;
問題我們,收件人只有一個,那不存在的郵箱。但是,當調用smtp.Send方法時,拋出以下異常:
{"No se pueden enviar todos los destinatarios."}
[System.Net.Mail.SmtpFailedRecipientsException]: {"No se pueden enviar todos los destinatarios."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
HResult: -2146233088
InnerException: {"El buzón de correo no está disponible. La respuesta del servidor fue: User unknown/Usuario desconocido/Usuario desconhecido"}
Message: "No se pueden enviar todos los destinatarios."
Source: "System"
StackTrace: " en System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)\r\n en System.Net.Mail.SmtpClient.Send(MailMessage message)\r\n en Common.MailHelper.Send(String toEmail, String toName, String ccEmail, String ccName, String subject, String body, MemoryStream attachment, String fileName) en c:\\WorkingFolder\\Proyectos\\Evcom\\Asistencia\\Nueva Normativa\\Asistencia\\Common\\MailHelper.cs:línea 55\r\n en Common.Ticket.Send(MailHelper mailHelper, MemoryStream pdfStream, String toEmail, String ccEmail) en c:\\WorkingFolder\\Proyectos\\Evcom\\Asistencia\\Nueva Normativa\\Asistencia\\Common\\Ticket.cs:línea 203"
TargetSite: {System.Net.Mail.MailWriter SendMail(System.Net.Mail.MailAddress, System.Net.Mail.MailAddressCollection, System.String, Boolean, System.Net.Mail.SmtpFailedRecipientException ByRef)}
你能幫我嗎?
該服務器是我的,我用它通過一個緊湊的框架應用程序發送電子郵件。在這種情況下,我使用其他smtp服務器帳戶發送電子郵件。我將嘗試使用與其他應用程序相同的SMTP參數。 – jstuardo