Sharad Mishra

Sharad Mishra

  • NA
  • 321
  • 6.8k

No error and not getting email to recepient inbox

Aug 9 2016 12:47 AM
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add("[email protected]");
mail.From = new MailAddress("[email protected]");
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.Credentials = new System.Net.NetworkCredential("[email protected]", "*****");
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);
}

Answers (5)