JMail | JMAIL Email Component Script by ASP Web Pro
  Active Server Pages Programming by ASP Web Pro

ASP Scripts

JMail

Another way to send form data is with the JMail component. In this script, we will send data from a basic text box and a textarea box.

The first thing you need to do is create a formpage.asp page with the code below:

<form name="YourFormName" method="Post" action="confirmation.asp">
<table>
<tr><td>Email: </td>
<td><input type="text" name="Email" size="50"></td></tr>
<tr><td>First Name: </td>
<td><input type="text" name="FirstName" size="50"></td></tr>
<tr><td>Last Name: </td>
<td><input type="text" name="LastName" size="50"></td></tr>
<tr><td>Subject: </td>
<td><input type="text" name="Subject" size="50"></td></tr>
<tr><td>Comments: </td>
<td><textarea name="Comments"></textarea></td>
</table>
<input type="submit" name="Submit" value="Submit Form">
</form>

Next, we create a confirmation.asp page and enter the code as seen below:

<%
DIM strEmail, strFirstName, strLastName, strSubject, strComments, Mailer
strEmail = Request.Form("Email")
strFirstName = Request.Form("FirstName")
strLastName = Request.Form("LastName")
strSubject = Request.Form("Subject")
strComments = Request.Form("Comments")

Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "mail.aspwebpro.com"
JMail.AddRecipient "general@aspwebpro.com"
JMail.Sender = strEmail
JMail.Subject = strSubject
JMail.Body = strComments
JMail.Execute
Set JMail= Nothing

IF NOT JMail.Execute THEN
Response.Write( "ERROR MESSAGE: " & JMail.ErrorMessage & "<BR>" & vbcrlf )
Response.Write( "ERROR SOURCE: " & JMail.ErrorSource & "<BR>" & vbcrlf )
Response.Write( "LOG: <pre>" & JMail.Log & "</pre>" & vbcrlf )
ELSE
Response.Write "<blockquote>Your :<b>" & strSubject & "</b> Newsletter has been successfully sent to <b>" & intSubscribers & "</b> subscribers.</blockquote>"
END IF
%>

Now you have a complete form that sends data to an email address and displays a customized message for your user. The default for JMail is to send text messages if you want to send HTML messages you can simply include this extra line of code before the JMail.Body line.

JMail.ContentType = "text/html"

Enjoy!

< Back to ASP Scripts


 

 

Main Menu
Home
ASP Scripts
ASP Tutorials
JavaScripts
Awards
Contact Us

Email This Page

Other Resources
ASP Web Hosting
Search Engine Submission
Programming Help

 

 

 

Other ASP Web Sites

Site Map

 

Last Updated:
21 March 2010