Sending Email From Asp.Net Page

To send A email from page using SMTP protocol follow following steps:

  • In web.config add following code


        <network host=""


         userName="your mail id"






  •  Add a C# function to send email
 protected void sendMail()
            MailMessage mailMessage = new MailMessage()
                Subject = contactSubject.Text,

                Body = contactBody.Text ,

                From = new MailAddress(contactEmail.Text),

                IsBodyHtml = true

            mailMessage.To.Add(new MailAddress(""));

            SmtpClient smtpClient = new SmtpClient();

            smtpClient.SendAsync(mailMessage, mailMessage);

            lblStatus.Visible = true;

            lblStatus.Text = "Your Request Submitted Successfully ..!!";

            lblStatus.Text = "Sorry Try Again Later..!!";

  • Call the above created function on any of the event such as button click, page load etc.


Sending Email From Asp.Net Page Sending Email From Asp.Net Page Reviewed by Atul Chavan on 6:15 PM Rating: 5
Powered by Blogger.