AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Friday 30 October 2015

Send Mail by gmail account in ASP.NET

You can integrate mail via gmail account but make sure that gmail settings allow less secure app. Click on Gmail settings & allow less secure app (gmail->Setttings->allow less secure app)

MailMessage mail = new MailMessage();
mail.From = new MailAddress("");
mail.Sender = new MailAddress("");
mail.IsBodyHtml = true;
mail.Subject = "Email Sent";
mail.Body = "Body content from";
SmtpClient smtp = new SmtpClient("", 587);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("", "your_password");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;
smtp.Timeout = 30000;
catch (SmtpException e)
    textBox1.Text= e.Message;


Post a Comment

  • Popular Posts
  • Comments