System.Net.Mail.SmtpException:
Failure sending mail. --->
System.Net.WebException:
Unable to connect to the remote server --->
System.Net.Sockets.SocketException:
No connection could be made because the target machine actively refused it xx.x.xx.xxx:25
我SMTP主機IP地址上面我無法得到它的郵件是拋出上述異常。下面的smtp例外無法發送郵件
是我的代碼
mail.From = new MailAddress(email.From.EmailAddress,email.From.FullName);
mail.Subject = email.Subject;
mail.Body = email.Body;
if (email.Body.Contains("<html>"))
{
mail.IsBodyHtml = true;
}
if (!email.ExcludeAttachment && !string.IsNullOrEmpty(email.AttachmentPath))
mail.Attachments.Add(new Attachment(email.AttachmentPath));
client = new SmtpClient();
client.Host = ConfigurationSettings.AppSettings["SmtpServer"].ToString();
client.Send(mail);
顯示您的代碼。 – Arash
mail.From = new MailAddress(email.From.EmailAddress,email.From.FullName); mail.Subject = email.Subject; mail.Body = email.Body; if(email.Body.Contains(「」)) { mail.IsBodyHtml = true; (email.AttachmentPath)) } if(!email.ExcludeAttachment &&!string.IsNullOrEmpty(email.AttachmentPath)) mail.Attachments.Add(new Attachment(email.AttachmentPath)); client = new SmtpClient(); client.Host = ConfigurationSettings.AppSettings [「SmtpServer」]。ToString(); client.Send(mail); –
這是我的代碼。 –