using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Hello World";
mail.Body = "
Hello
"; mail.IsBodyHtml = true;
// mail.Attachments.Add(new Attachment("C:\\file.zip"));
using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
{
smtp.Credentials = new NetworkCredential("[email protected]", "password");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Send(mail);
}
}
Error:-
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ravi PatelPosted Jun 3, 2016, 1:29 AM
Rajeesh MenothPosted Jun 3, 2016, 12:15 AM