System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.Subject = "This mail is send from asp.net application";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "This is Email Body Text";
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "smtp.gmail.com";
//client.EnableSsl = true;
SmtpClient smtp = new SmtpClient();
smtp.SendCompleted += new SendCompletedEventHandler(smtp_SendCompleted);
smtp.Send(mail);
try
{
client.Send(mail);
//Page.RegisterStartupScript("UserMsg", "<script>alert('Successfully Send...');if(alert){ window.location='SendMail.aspx';}</script>");
string strAlertMessage = "Mail Send succesfully";
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strAlertMessage + "');", true);
}
catch(Exception ex)
{
Console.Write(ex);
}