How to mail using ASP.NET?

You can create a mail form in asp.net.

1. Create a html form which will get the values from the user.

For Example:
<form method="POST" action="test.aspx">

To <input type="text" name="To">

From <input type="text" name="From">

Subject <input type="text" name="Subject">

Body <textarea name="Body" rows="5" cols="20" wrap="physical">

2. Add the following code into the file test.aspx.

<% @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");
%>

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

We are receiving the error Secure Connection Failed while opening https? What is the problem?

Security Certificates: Secure Connection Failed : Firefox uses certificates on secure websites...

What are the process involved in authenticating the mail in ASP?

What are the process involved in authenticating the mail in ASP? Use the below mentioned contents...

How to setup a access database in plesk?

Access database (mdb) in Plesk - How to setup a access database in plesk Upload the mdb file in...

How to create an email account?

Adding Email Accounts You can create email accounts with your domain name using the following...

How to authenticate the mail in ASP?

How to authenticate the mail in ASP? You can use the below mentioned content to authenticate the...