2

I made an e-mailer in C#, but you have to enable less secure apps in google. Is there a way around this? If not, how do other apps send e-mails securely without being classified as a less-secure app?

private void SendButton_Click(object sender, EventArgs e) {
       try {
           SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

           mail.From = new MailAddress(myUsername);
           mail.To.Add(RecipientEmailBox.Text);
           mail.Subject = SubjectField.Text;
           mail.Body = MessageField.Text;

           SmtpServer.Port = 587;
           SmtpServer.Credentials = new 
           System.Net.NetworkCredential(myUsername, Login.password);
           SmtpServer.EnableSsl = true;

           SmtpServer.Send(mail);
           MessageBox.Show("Message Sent!");

       } catch (Exception ex) {
           MessageBox.Show(ex.ToString());
       }
}

I tried researching ways to get around this, but I couldn't find anything.

DiplomacyNotWar
  • 31,605
  • 6
  • 57
  • 75
Spencer1O1
  • 298
  • 5
  • 15

1 Answers1

1

I think this is answer for question.

You can use the Google OAuth API with C#. For how to do, read the guide.

OnePage
  • 81
  • 1
  • 13