DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Send Email From Asp.net Page

11.30.2009
| 4135 views |
  • submit to reddit
        Quick and simple send email from asp.net page.

<%@ Page Language="C#" %>
<%
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("localhost");

            System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress(<<sender>>);

            System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(<<recipient>>);

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to);

            message.Body = "This is a test e-mail message sent by an application. ";

            message.Subject = "<<subject>>";

            client.Send(message);

            message.Dispose();

%>