| w3JMail Examples |
Examples 3.7
|
This is a different way to handle forms. Instead of specifyingeach field as in the forms example, we now read all form fields and paste their values into our e-mail. |
First, a sample form. Any form will do as long as it posts to our JMail page. |
JmailForm.asp
<html>
<head> <title>emailform</title> </head> <body> <form method="post" action="SendMail.asp"> Name <INPUT name="name" type="text"><br> Email<INPUT name="Email" type="text"><br> Company<INPUT name="company" type="text"><br> Occupation <SELECT name="state"> <OPTION value="coder">Coder <OPTION value="coder">Hacker <OPTION value="coder">Developer <OPTION value="coder">Guru </SELECT><BR> Favorite TV-show<TEXTAREA name="tv-show"></TEXTAREA> <br> <INPUT type="submit" value="Send"> </form> </body> </html> |
Now we use the forms collection to get all the fields and adde their values to the e-mail. |
SendMail.asp<html> <head> <title>Confirmation</title> </head> <body> <% Set JMail = Server.CreateObject("JMail.SMTPMail") ' This is my local SMTP server JMail.ServerAddress = "mail.dimac.net" ' This is me.... JMail.Sender = "mrsmith@acme.com" JMail.Subject = "Here you go..." ' Get the recipients mailbox from a form (note the lack of a equal sign). JMail.AddRecipient "drdoo@perky.com" JMail.Priority = 1 JMail.body = "The form was filled out with the following values:" & vbcrlf Dim el 'add every form element and its value to the email FOR EACH el IN Request.Form JMail.appendtext( el & ": " & Request.form(el) & vbcrlf ) NEXT ' Send it... JMail.Execute %> <center> An e-mail has been sent to your mailbox (<%=request.form("email")% >). </center> </body> </html> |
|
|