1. Computing

Discuss in my forum

How to Send a Simple Email with ASP.NET

By

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.

©2014 About.com. All rights reserved.