How to mail using ASP?

You can create a mail form in asp.

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

For Example:
<form method="POST" action="email.asp">

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">

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

<%
Dim objMail, objMailConf
Set objMail = Server.CreateObject("CDO.Message")
Set objMailConf = Server.CreateObject("CDO.Configuration")
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '2 for web server
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:inetpubmailrootpickup"
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objMailConf.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
objMailConf.Fields.Update
Set objMail.Configuration = objMailConf
objMail.From = "someone@gmail.com"
objMail.To = Request.Form("To")
objMail.Subject = Request.Form("Subject")
objMail.TextBody = Request.Form("Body")
objMail.Fields.Update
objMail.Send
Set objMail = Nothing
Response.Write "Mail Sent Successfully"
%>

Was this answer helpful?

 Print this Article

Also Read

How to access the MSSQL 2008 database using Remote Database Connectivity?

How to access the MSSQL database using Remote Database Connectivity? Follow the below to access...

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...

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 do i disable directory listing from Plesk?

Disable Directory Listing Step 1:Login to Plesk Step 2:Goto Domains -> Domain Name -> Web...

How to redirect using Plesk ControlPanel?

Redirect Using Plesk Step 1:Login to plesk control panel. Step 2:Select Mail. Step 3:Select on...