Shubham Agrawal

Shubham Agrawal

  • 1.5k
  • 218
  • 6.9k

how to send mail

Sep 20 2017 3:48 AM
This Code is using For Sending Mail
but i Dont Sent the mail. Can anyone help Me ASAP.
 
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress("[email protected]");
mail.To.Add(textbox3.Text);
mail.Subject = "Random Password for your Account";
mail.Body = "You Are Successfully Register...!!!\n\nDear " + textbox1.Text + "," + "\n" + strNewPassword + "," +
"\n\tThank you registering for Onlile Shopping As A Member." +
"\nIf you have any query please contact 8319058205." +
"\nThank you and Have a nic Day....!" +
"\n\n[Mr.Shubham Agrawal]";
mail.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential networkCredential = new NetworkCredential();
networkCredential.UserName = "[email protected]";
networkCredential.Password = "*******";
smtp.UseDefaultCredentials = true;
smtp.Credentials = networkCredential;
smtp.Port = 587;
smtp.Send(mail);
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Message has been sent successfully.');", true);
}

Answers (6)