| w3JMail Examples |
Examples 3.7
|
One of the most common uses for Dimac w3 JMail is when a form is filled out by the user and then emailed by ASP. This example shows you just how easy it is. |
First of all we need a form which posts to our JMail page. |
JmailForm.asp
<html>
<head> <title>emailform</title> </head> <body> <form method="post" action="SendMail.asp"> Complete this form and click the submit-button. We will answer your questions as soon as possible. <br><br> Your name<br> <input type="text" size="25" name="name"><br> Your email<br> <input type="text" size="25" name="email"><br> Recipient email<br> <input type="text" size="25" name="recipient"><br> State your business<br> <select name="subject" size="1"> <option value="help">help <option value="tips">tips <option value="other">other </select> <br> Enter your question<br> <textarea name="body" cols="40" rows="15" wrap="PHYSICAL"></textarea> <br> <input type="submit" value=" Submit "> </form> </body> </html> |
Then we need to catch the post and read the form. Pick up all information and create the e-mail. |
SendMail.asp<html> <head> <title>w3 JMail rocks</title> </head> <body> <p align="center"><font face="Arial, geneva" size="5"> Email Form</font></p> <% Name = Request.Form("name") SenderEmail = Request.Form("email") Subject = "Regarding " & Request.Form ("subject") Recipient = Request.Form("recipient") Body = Request.Form("body") Set JMail = Server.CreateObject ("JMail.SMTPMail") ' Below you should enter your own SMTP-server JMail.ServerAddress = "xxx.zzz.yyy" JMail.Sender = Senderemail JMail.Subject = Subject JMail.AddRecipient Recipient JMail.Body = Body JMail.Priority = 3 JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR") JMail.Execute %> <center> <font face="Arial, geneva" size="3"> Your email has been sent to<%= Recipient % ><br> </font> </center> </body> </html> |