Sharad Mishra

Sharad Mishra

  • 1.7k
  • 310
  • 5.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("anjani.ctcz@gmail.com");
mail.From = new MailAddress("shardendumishra85@gmail.com");
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("xyz@gmail.com", "*****");
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)