MailMessage mm = new MailMessage("teztag.web1@gmail.com", "teztag.web2@gmail.com");
mm.Subject = "Password";
mm.Body = "body";
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "teztag.web1@gmail.com";
NetworkCred.Password = "password";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
Check this link
https://myaccount.google.com/lesssecureapps?pli=1
& change the setting as bellow:-
Allow less secure apps: ON
No comments:
Post a Comment