Well, you clearly didn't try
everything, or you'd have found the answer already! :)
Important
We don't recommend that you use the SmtpClient
class for new development because SmtpClient
doesn't support many modern protocols. Use MailKit[^] or other libraries instead. For more information, see SmtpClient shouldn't be used on GitHub[^].
As the documentation says, the
System.Net.Mail
classes
do not support modern protocols such as OAuth. If you need to support them, then you'll need to change your code to use a different library.
MailKit provides instructions for integrating with MS Exchange and GMail:
MailKit/ExchangeOAuth2.md at master · jstedfast/MailKit · GitHub[
^]
MailKit/GMailOAuth2.md at master · jstedfast/MailKit · GitHub[
^]
Other providers should follow a similar pattern.