Send Email to from C# after 5/30/2022

Bill Bell 6 Reputation points

I have a C# program which sends mail using as SMTP server.  It uses  System.Net.Mail.  I use my email address and password and turn on "Allow less secure apps" option in my GMAIL account. Everything works well.  On May 30, 2022 Google will disable "Allow less secure apps".  Has anyone addressed this issue.

On my Gmail Account.
Some apps and devices use less secure sign-in technology, which makes your account vulnerable. You can turn off access for these apps, which we recommend, or turn it on if you want to use them despite the risks. Google will automatically turn this setting OFF if it’s not being used. Learn moreAllow less secure apps: ONOn May 30, 2022, this setting will no longer be available. Learn more

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,189 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Bruce ( 36,026 Reputation points

    you need to convert to oauth authentication:

    you may want to use a clientid

    if it is a program with a UI you may want to host a web view for login to get the token. you can also use httpclient post the form and host web server port for the authentication server to redirect back to. (register localhost:<port> as a valid reply url).

    if the application does not have a UI, you will want a separate program with a UI that saves the refresh token somewhere the app can access. The token will expire and need to be updated periodically.

    1 person found this answer helpful.
    0 comments No comments

  2. Castorix31 71,621 Reputation points
    1 person found this answer helpful.
    0 comments No comments