Send Email using Office365 - C#

Send Email using Office365 - C#

code snippet

c#
using (var client = new SmtpClient{
Credentials = new System.Net.NetworkCredential("username", "password"),
Port = 587, // You can use Port 25 if 587 is blocked 
Host = "smtp.office365.com";
}){
var mail = new MailMessage();
mail.From = new System.Net.Mail.MailAddress("from@email.com");
mail.To.Add("to@email.com"); 
mail.Subject = "Email Subject";
mail.Body = "Email Body";
mail.IsBodyHtml = false; // or true
try{
    client.Send(mail);
}
catch (Exception){
}

"The measure of who we are is what we do with what we have"

Contact me!

Have questions? Feel free to use the form or send me an email with any questions.

I will be responsive to your requests and your questions.