Possible Duplicate:
How to use gmail SMTP in ASP.NET form
getting exception while sending mail. -The remote certificate is invalid according to the validation procedure. Need solution. My Code is :
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;
}
}