I'm working in windows application and C#, I am using following code to send email. The Code not works correctly in my system:
MailMessage mailmsg = new MailMessage();
SmtpClient smtpclient = new SmtpClient();
mailmsg.To.Add(txtTo.Text);
mailmsg.CC.Add(txtCC.Text);
mailmsg.Subject = txtSubj.Text;
mailmsg.From = new MailAddress("buvana@gmail.com");
mailmsg.Body = txtbody.Text;
smtpclient.Port = 587;
smtpclient.Host = "smtp.gmail.com";
smtpclient.EnableSsl = true;
smtpclient.UseDefaultCredentials = false;
smtpclient.Credentials = new NetworkCredential("buvana@gmail.com", "*********");
smtpclient.Send(mailmsg);
How to solve this problem.
Received this error:
SMTP server requires a secure connection or the client was not authenticated
The server response was: 5.5.1 Authentication Required