发送邮件时出现异常。- 根据验证程序,远程证书无效。需要解决方案。我的代码是:
public bool mailSender(string toMailId, string uniqueGuid)
{
try
{
SmtpClient smtpClient = new SmtpClient();
string linkForConfirm = "orderConfirmation.aspx?id=" + uniqueGuid;
string Subject = "Shiv Cart Grocery Shop Confirmation";
string body = " <div style='width:700px; margin:0 auto;'><div style='background-color:#800000; width:700px'>";
body += "</div><div><h2>Shiv Cart Grocery Shop</h2><h3 style='color:#0099FF; width:700px'> Click Below To Confirm Your Order</h3>";
body += "<a href='" + linkForConfirm+ "' id='a' ></a></div></div>";
MailAddress fromMailAddress = new MailAddress("mail@sumedhasoftech.com", "Shiv Cart");
MailAddress toMailAddress = new MailAddress(toMailId);
MailMessage mail = new MailMessage(fromMailAddress, toMailAddress);
mail.Subject = Subject;
mail.Body = body;
mail.IsBodyHtml = true;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Credentials = new System.Net.NetworkCredential(WebConfigurationManager.AppSettings["MailSenderUserName"].ToString(), WebConfigurationManager.AppSettings["MailSenderPass"].ToString());
smtpClient.EnableSsl = true;
smtpClient.Send(mail);
return true;
}
catch (Exception)
{
return false;
}
}