Using ASP for Form Handling
July 31, 2000
|
In this article, we will discuss how to use Microsoft ASP technology to
handle user-submitted form data and then send that data to someone via
email with Microsoft's Collaboration Data Object for NT Server (CDONTS).
|
Introduction
Microsoft's Active Server Page technology is a powerful server-side
scripting method of web development that allows any web developer with a
web server powered by NT's Internet Information Services (IIS) and a basic
understanding of
HTML and VBScript to create powerful dynamic
web pages.
This article assumes that you have the basic HTML and VBScript understanding
mentioned above. However, I will explain anything that is crucial to your
understanding.
If you have ever created or thought about creating an HTML form for user
input on your web site, then you must have also dealt with the issue of
handling the data once it is submitted (ie. where does the data go and how
does it get there). As you may already know, if you want the information
submitted to be emailed to you, you can simply put your email address in the
action field of the FORM tag like this:
<form action="mailto:corinth@enfused.com" method="get" enctype="text/plain">
TIP:
If you do not have time or the resources to program an
ASP page or
Perl script to handle your
form's submitted data, you can use a little-known HTML trick to make
the submitted form data reach your inbox in a legible fashion. By
adding enctype="text/plain" to your form tag,
the output will come across as standard plain text rather than that
garbled mess that normally comes across when you set the action
equal to mailto:some_email@address.com.
|
However, you probably also know that when you use the
mailto action, your users will get an obnoxious and
frightening security warning, and we do not want to scare your users away!
To avoid the security alert, you have a couple of options. First, if you
are developing in a
UNIX environment, using Perl and
CGI would probably be your best bet. If that
is the case, you should check out Aaron Weiss'
The Perl You Need to Know series of articles here at the WDVL.
On the other hand, if you are developing in an NT environment, while you
may still use Perl and CGI if Perl is installed on your server, it is
recommended that you use ASP because it is easier to code and a bit more
intuitive, for novices and experts alike.
In the remainder of this article, I will show you how to use ASP to handle
the form data and then send it to an email address using the Collaborative
Data Object for NTS (CDONTS), a special Windows NT COM object designed to
send mail through the SMTP service on your web server.
Contents:
Creating the Form
Adding the ASP Code
Making the ASP Page Smart
Working with CDONTS
Putting It All Together and Wrapping Up
Creating the Form
|