Unable to send the email in office 365 in C# error

Viewed 1668
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("admin@xxxxxxxx.in");
mailMessage.To.Add(new MailAddress("sales@xxxxxxxx.in"));
mailMessage.Subject = "Test Subject";
mailMessage.Body = "Testing Office365 Email";
mailMessage.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("admin@xxxxxxxx.in", "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 Answers
Related