Send an Office365 SMTP mail in .NET/C#

Sending a mail using Office365 is no big deal. It is just similar to how you send a mail via any SMTP server. But you will have to mind the SMTP host, port number and remember to enable SSL in the code. Here goes the code snippet:

using (MailMessage message = new MailMessage())
    message.From = new MailAddress("");
    message.Subject = "test mail";
    message.Body = "


"; message.IsBodyHtml = true; SmtpClient client = new SmtpClient("", 587); client.Credentials = new NetworkCredential("", "passwordhere"); client.EnableSsl = true; client.Send(message); }