0

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("my365email@domain.com");
                    MailAddress toAddress = new MailAddress("toaddress@yahoo.com");
                    smtpClient.Credentials = new System.Net.NetworkCredential("my365email@domain.com", "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);
Hasan Zubairi
  • 1,037
  • 4
  • 23
  • 57

0 Answers0