priteshjoshi
New member
- Joined
- Aug 25, 2018
- Messages
- 1
- Programming Experience
- 10+
Dear Friends,
I am trying to send email through gmail.Getting error "The SMTP server requires a secure connection or the client was not authenticated.The server response was: 5.5.1 Authentication Required".
try
{
SmtpClient clientSMTP = new SmtpClient("smtp.gmail.com", 587);
clientSMTP.EnableSsl = true;
clientSMTP.DeliveryMethod = SmtpDeliveryMethod.Network;
clientSMTP.UseDefaultCredentials = false;
clientSMTP.Credentials = new NetworkCredential("pritesh.joshi@gmail.com", "Password");
using (MailMessage message = new MailMessage())
{
message.From = new MailAddress("pritesh.joshi@gmail.com");
message.Subject = "Subject";
message.IsBodyHtml = true;
message.To.Add("pritesh.joshi@gmail.com");
message.Body = "Hi " + "Suresh" + "!\n" + "Welcome to C# Corner!" + "Please <a href='" + " http://windowsapptutorials.wordpress.com/ " + "'>click</a> here to activate your account. \nThanks!";
clientSMTP.Send(message);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{ }
I am trying to send email through gmail.Getting error "The SMTP server requires a secure connection or the client was not authenticated.The server response was: 5.5.1 Authentication Required".
try
{
SmtpClient clientSMTP = new SmtpClient("smtp.gmail.com", 587);
clientSMTP.EnableSsl = true;
clientSMTP.DeliveryMethod = SmtpDeliveryMethod.Network;
clientSMTP.UseDefaultCredentials = false;
clientSMTP.Credentials = new NetworkCredential("pritesh.joshi@gmail.com", "Password");
using (MailMessage message = new MailMessage())
{
message.From = new MailAddress("pritesh.joshi@gmail.com");
message.Subject = "Subject";
message.IsBodyHtml = true;
message.To.Add("pritesh.joshi@gmail.com");
message.Body = "Hi " + "Suresh" + "!\n" + "Welcome to C# Corner!" + "Please <a href='" + " http://windowsapptutorials.wordpress.com/ " + "'>click</a> here to activate your account. \nThanks!";
clientSMTP.Send(message);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{ }