1
votes
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]");
mailMessage.To.Add(new MailAddress("[email protected]"));
mailMessage.Subject = "Test Subject";
mailMessage.Body = "Testing Office365 Email";
mailMessage.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("[email protected]", "xxxxxxxx");
client.Port = 465;
client.Host = "smtp.office365.com";
client.EnableSsl = true;
client.Send(mailMessage);

Getting following error message.
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail. Error: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant." Please help me to resolve the issue, thanks in advance.

1

1 Answers