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

Was this answer helpful?

 Print this Article

Also Read

How to reset password for email accounts?

Step 1: Login to your plesk control panel. Step 2: Click Mail Accounts. Step 3: Click the...

How to create Database and user to the Database in Plesk?

Create Database You can create database using the following steps. Step 1: Login to the Plesk....

How can I access Webmail from outside of Plesk?

Access Webmail - You can access the Webmail from outside of Plesk Control panel by typing...

How to authenticate the mail in ASP?

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

How to create or edit the MX windows in plesk windows server

Login to your Plesk using the username and password associated with your domain. In right pane...