Mail Send With Html Content




public String SendConfirmationEmailNew()
{
StringBuilder sb = new StringBuilder();
sb.Append("***HTML CODE***");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("***Mail Id****");
msg.To.Add(emailid);
msg.Subject = "Courserebel User Confirmation";
msg.Body = Convert.ToString(Convert.ToString(sb));
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
client.EnableSsl = true;
msg.IsBodyHtml = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new NetworkCredential("***Mail ID***", "***password***");
client.Timeout = 20000;
try
{
client.Send(msg);
return "Mail has been successfully sent!";
}
catch (Exception ex)
{
return "Fail Has error" + ex.Message;
}
finally
{
msg.Dispose();
}
}