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