Система. Net .Mail.SmtpException: 'SMTP-сервер требует защищенного соединения или клиент не прошел аутентификацию. Ответ сервера: 5.7.0 Требуется аутентификация.
using (SqlConnection con = new SqlConnection(ApplicationSettings.ConnectionString()))
{
con.Open();
//try
//{
SqlCommand cmd = new SqlCommand("SELECT [Email Address] FROM [Staff] WHERE [Access Level]='Manager'", con);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
string emailaddress = Convert.ToString(sdr["Email Address"]);
MailMessage mail = new MailMessage();
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("possystemmahdealjamil@gmail.com");
mail.To.Add(emailaddress);
mail.Subject = "Todays POS System Reports";
mail.Body = "Todays shift is closed at"+DateTime.Now.ToString();
smtpServer.Port = 587;
smtpServer.Credentials = new [enter image description here][1]System.Net.NetworkCredential("possystemmahdealjamil@gmail.com", @"###########");
smtpServer.EnableSsl = true;
smtpServer.Send(mail);
MessageBox.Show("Mail is Send Successfully ", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.Message, "open shift failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
//finally
//{
// con.Close();
//}
}