I need to use a company shared account (email address is removed for privacy) to send notifications, but fails all the time. I tried all possible codes with no luck.
So, I had a little suspicious about the account. Then I used my office 365 work account, and it is working as expected. But I still need to use the shared account.
The error information is as follows:
Message = "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 [D*******8.na***11.prod.outlook.com]"
var message = new MailMessage("from", "to", "MySubject", "MyBody");
SmtpClient client = new SmtpClient("outlook.office365.com");
client.EnableSsl = true;
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("username", "password");
client.Send(message);