Sending email in ASP.NET

Sending mail in ASP.NET is simple! You just create a message and then call the SmtpMail’s static send method:

MailMessage message = new MailMessage();message.To = "";message.From = "";message.Subject = "An email from helen";message.Body = "Hello Helen. From Helen.";SmtpMail.Send(message);

If you need to talk to a non-local server, that’s not really much more difficult. You just specify a SmtpServer address in the SmtpMail object before you send:

SmtpMail.SmtpServer = ""; SmtpMail.Send(message);

If your SMTP server requires authentication, just specify your username and password with the following fields in your message object before you send it:

message.Fields[""] = 1;message.Fields[""] = "myusername";message.Fields[""] = "mypassword";


4 guys email tutorial

Microsoft mail object documentation

Usenet post explaining how to set username and password

Posted on 08 Dec 04 by Helen Emerson (last updated on 08 Dec 04).
Filed under ASP.NET