0

this is the way i'm sending the email

try
            {
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress("[email protected]");
                    mail.To.Add("[email protected]");
                    mail.Subject = "Hello World";
                    mail.Body = "<h1>Hello</h1>";
                    mail.IsBodyHtml = true;
                    using (System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587))
                    {
                        smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
                        smtp.EnableSsl = true;
                        smtp.UseDefaultCredentials = false;
                        smtp.Send(mail);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

I did already activate the less secure app in account security setting.

This is the exception error :

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Thameur Saadi
  • 159
  • 1
  • 8

0 Answers0