我无法发送邮件,例外情况“发送邮件失败”
我该怎么做才能纠正这些代码?
MailMessage mailMessage = new MailMessage("yourmail@mail.com", ToEmail);
StringBuilder sbEmailBody = new StringBuilder();
sbEmailBody.Append("<b>Registration Approval for</b></br>");
sbEmailBody.Append(InstituteName + "<br/><br/>");
sbEmailBody.Append("Thanks for your registration ");
sbEmailBody.Append("<br/>");
mailMessage.IsBodyHtml = true;
mailMessage.Body = sbEmailBody.ToString();
mailMessage.Subject = "Confirmation Mail!";
SmtpClient smtpClient = new SmtpClient("smtp.mail.com", 587);
smtpClient.Credentials = new System.Net.NetworkCredential()
{
UserName = "yourmailn@mail.com",
Password = " "
};
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);