Email

  1. Home
  2. Computing & Technology
  3. Email

How to Send a Simple Email with ASP.NET

By Heinz Tschabitscher, About.com

Sending a simple email from an ASP.NET is just as simple as (and looks very similar to) doing the same in PHP.

Send a Simple Email with ASP.NET

First, we need to import the System.Web.Mail namespace:

<%@ Import Namespace="System.Web.Mail" %>

Sending the message is a matter of calling SmtpMail.Send() with the following arguments: sender, recipient, subject and body. For example, we'd send an email in C# like this:

string from = "sender@example.com";
string to = "recipient@example.com";
string subject = "Hi!";
string body = "How are you?";
SmtpMail.SmtpServer = "mail.example.com";
SmtpMail.Send(from, to, subject, body);

SmtpMail.SmtpServer lets you specify the mail server used to deliver your message.

More Email Quick Tips

Explore Email

About.com Special Features

Email

  1. Home
  2. Computing & Technology
  3. Email
  4. How Email Works
  5. Email Programming Tips
  6. How to Send a Simple Email with ASP.NET - About Email

©2009 About.com, a part of The New York Times Company.

All rights reserved.