I want to send users emails from my webapp hosted in Azure. I've been following a tutorial and have this code (filled in with my details, of course):
public void SendEmail() { var client = new SmtpClient("smtp.office365.com") { Port = 587, UseDefaultCredentials = false, Credentials = new NetworkCredential("user", "password") }; var mailMessage = new MailMessage {From = new MailAddress("user")}; mailMessage.To.Add("toaddress"); mailMessage.Body = "Test"; mailMessage.Subject = "Hello"; client.Send(mailMessage); }
However I have not had any success yet. I get a TimeoutException
so
I believe there is an issue with contacting the SMTP server.
Has anyone had any success with using Office365 to send emails? For clarity the company I work for does use Offce365 and I have a registered email address.