email sender c# code not working in asp.net mvc web app RRS feed

  • Question

  • "Hi, I am using 'System.Net.Mail.SmtpClient' to send email notifications from my ASP.Net C# MVC web project using OFFICE365 EMAIL ID as Sender. It was working correctly a few months back but stop working when Microsoft Authenticator introduced for MS Apps. Please let me know in case you face this issue and better if you tell me it fixes."

    Code =>

     SmtpClient client = new SmtpClient("smtp.office365.com", 587);
                client.EnableSsl = true;
                client.UseDefaultCredentials = false;
                client.Credentials = new NetworkCredential("*****", "*****");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Timeout = 100000;
                MailMessage msg = new MailMessage();
                msg.From = new MailAddress("*******");
                msg.Subject = "Test";
                msg.Body = "Testing";

    Exception =>

    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP;

    Client was not authenticated to send anonymous mail during MAIL FROM [BM1PR0101CA0062.INDPRD01.PROD.OUTLOOK.COM]

    Friday, December 11, 2020 12:19 PM

All replies