I am trying to send mails using Gmail in my code. It gives me error.
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. "
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com",587);
//smtp.Credentials = new NetworkCredential("manishchourasia2000@gmail.com", "justdoit");
System.Net.NetworkCredential nc = new NetworkCredential("manishchourasia2000@gmail.com", "justdoit", "smtp.gmail.com"); //smtp.Credentials.GetCredential("smtp.gmail.com", 995, "");
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = nc;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
MailMessage mm = new MailMessage("manishchourasia2000@gmail.com", "manish.chourasia@inecomworld.com", "Gmail Testing", "Gmail Testing");
smtp.Send(mm);
I tried many possibilities but nothing work.
Aucun commentaire:
Enregistrer un commentaire