Send E-mail using ASP.Net

Send e-mail using c# in ASP.Net.


first Import the below namespace in your web application.

  • using System.Net.Mail; 

Code for Send email using ASP.Net

  • MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress(“meera@academy.com”, YourName);
    message.From = fromAddress;

    message.To.Add(“info@academy.com”);  message.Subject = “Meera Academy – Information”;
    message.IsBodyHtml = false;
    message.Body = “Your Message”;

    SmtpClient sc = new SmtpClient();

    sc.Host = “smtp.gmail.com”;                           
    sc.Port = 587;
    sc.Credentials = new System.Net.NetworkCredential(“demo@gmail.com”, “gmailpassword”);

             sc.EnableSsl = true;

    sc.DeliveryMethod = SmtpDeliveryMethod.Network;
    sc.Send(message);

Leave a Reply

Your email address will not be published. Required fields are marked *

five + four =