Search This Blog

Pages

Sunday, February 13, 2011

Mail Code - ASP.NET

It is easy to create mail form using ASP.NET

Example:

First we have to create a html form which will get the values from the user as

To

From

Subject

Body






This form when submitted will be posted to a page called test.aspx
In the file test.aspx we will get the submitted values and send it as email

CODE

<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
<%
string strTo = "test@test.com";
string strFrom = "test@dnswind.com";
string strSubject = "Hi Test";

SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(strFrom, strTo, strSubject, "A real nice body text here");

Response.Write("Email was queued to disk");
%>

No comments:

Post a Comment