Monday 19 March 2018

Send Email through smtp.office365.com or Microsoft Office 365 in Asp.Net

Send SMTP email testing Microsoft Office 365 in .net

Description:

In this example we explain that how to send an Email using Microsoft Office 365 in Asp.Net.or how to send Email through smtp.office365.com in asp.net. or how to send new email using SMTP in Office 365 in Asp.Net.

So here we demonstrate that how to send email through Dynamic Office 365 credential in Asp.Net.or how to setup the Office 365 mail in Asp.net to sending the Emails through web application.
Code:

String userName = "username";
    String password = "password";
    MailMessage msg = new MailMessage("from email ", "to email");
    msg.Subject = "Your Subject Name";

    msg.Body ="body";
    SmtpClient SmtpClient = new SmtpClient();
    SmtpClient.UseDefaultCredentials = false;
    SmtpClient.Credentials = new System.Net.NetworkCredential(userName, password);
    SmtpClient.Host = "smtp.office365.com";
    SmtpClient.Port = port number;
    SmtpClient.EnableSsl = true;
    SmtpClient.Send(userName, "to email", "Test", "Test Body");




0 comments:

Post a Comment