
|
|
|||
Emailing Form Data with ASPBy Amrit Hallan2005-06-01
Emailing Form Data with ASP Recently a client asked me to write a CGI program to handle the form output at his site. As usual, he wanted the form content, entered by the visitor, to be sent to him in a readable format. As you have read above, my knowledge of Perl is not exactly enough to enable me to write serious CGI routines. I was about to refer him to a friend of mine, when I noticed (I haven't developed his site) that his site has been developed in ASP (no programming, just HTML pages saved as something.asp). Voila! Writing a form handling routine in ASP is cake walk. Here is how we do it. We'll use the CDO (Collaborative Data Object) email object that comes with NT and other compliant systems. Don't get much bothered. You can always call up your web host and find out what email object is being used. The methodology, in ASP, is almost the same. There are two methods actually. Preferred by advanced developers is the one in which we have the form and the processing code (the one that is mentioned with <form action="">) in the same file. Suppose we have a file named formthings.asp. I leave the HTML things to your capable intellect, and get my hands dirty straightaway with ASP. At the onset of the ASP code (that we are going to write in VBScript), we check how the file is being called. <% This method is a bit complicated for a newbie, as there could be too many if_then_else_end_if nests. So what we're going to do is, we are going to divide the work in two files. The first one simply contains a form that executes the file that emails the form content to a specified email address. Let the first file be form.asp that has the following form: <form method="post" action="sendemail.asp"> You can see that this form calls "sendemail.asp", which contains the following code: <% Dim sName, sEmail, sMessage, oSendMailer Error could occur if you supply wrong values, or if there is a problem in the server. So this is how you can email to you the form content from your web site. Tutorial Pages: » Emailing Form Data with ASP
|
||||
| About the NetVisits, Inc Network | Write For Us | Advertise Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy. |
Visit other NetVisits, Inc. sites: |