For an app I am writing an api service in c#. The site is hosted on a godaddy server. We have a office 365 account as well. I am trying to send main in my c# code through this accounts credentials. Earlier we had elasticemail smtp account. The same code was working fire with elasticemail account. But this code is not working with office 365 account.
smtpClient.Host = "smtp.office365.com";
smtpClient.EnableSsl = true;
smtpClient.Port = 25;
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("[email protected]");
MailAddress toAddress = new MailAddress("[email protected]");
smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
message.From = fromAddress;
message.To.Add(toAddress);
message.Subject = "This is the subject line";
message.Body = "This is a test mail";
smtpClient.Send(message);