Unable to send the mails through office 365

CD_TVFS 6 Reputation points
2022-10-20T10:55:55.153+00:00

We have a functionality in our Dot.net/C# based application which creates an outlook mail and sends to the recipients on their outlook email id. Up till now, it has been working fine but since last week, it has stopped working such that the mails are not getting sent to the recipients. Upon debugging, we found that it is giving an exception error as “The request failed. The remote server returned an error: (401) Unauthorized”. After finding solutions over various portals and taking help from our internal Infra team, we got to know that, to connect with server to send the mail, up till base authentication/protocol was used. But now, since Microsoft has enforced to the clients users to shift towards Modern authentication- OAuth 2.0, we are struggling to incorporate the same into our existing code and setup. We need assistance in knowing the steps in simple manner required to shift to Modern protocols.

C#
C#
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.
11,111 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 68,236 Reputation points
    2022-10-20T15:26:40.987+00:00

    You don’t which library you are using to send mail. If it is system.net.mail you will need a replacement library. Microsoft suggests graph api, but you can find smtp libraries that support oauth,

    The libraries that support oauth often require you to supply the code to fetch the token.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.