Select Category
Sitemap Help Contact
print article

Send an E-mail Using ASP.NET

Follow the steps below to send an e-mail through ASP.NET using the System.Net.Mail namespace.

Use the script below as an example for how to sned an e-mail using the System.Net.Mail namespace now that System.Web.Mail has been deprecated.

<%@ Import Namespace="System.Net"%>
<%@ Import Namespace="System.Net.Mail"%>
<%@ Page Language="C#" %>

//create the mail message
MailMessage mail = new MailMessage();
//set the FROM address
mail.From = new MailAddress("");
//set the RECIPIENTS
//enter a SUBJECT
mail.Subject = "Set the subject of the mail here.";
//Enter the message BODY
mail.Body = "Enter text for the e-mail here.";
//set the mail server (default should be
SmtpClient smtp = new SmtpClient("");
//Enter your full e-mail address and password
smtp.Credentials = new NetworkCredential("", "yourEmailPassword");
//send the message


For additional information, you may want to reference: