![]() | |||||||||||||||||||||
![]() |
|
|
by Derrald Farnsworth-Livingston Technical Setup Stuff
In this document we will discuss how to write an ASP Script to send emails. There are many benefits to this. For instance, perhaps you have a mailing list (like tutorial-web) that you want to have people be able to sign up for. However, when they have successfully inputted their email address you would like them to receive a confirmation. In addition, this can be an added check for you. If you receive a non-delivery message from the server than you know that the email address is bogus.
Technical Setup Stuff
The first thing is we must have a SMTP server through which we can relay email. Internet Information Server 4.0 and higher comes with such a service we can install. We must check to make sure that the relay settings are enabled. We can do this by:
Code, Code, Code
We shall begin by setting up a variable to be associated with the CDONTS.Newmail object in the ASP Script. This can be accomplished by way of the Createobject command.
Once we have set up the Object we now need to associate the properties with the values of the email we want to send.
The From, To, Subject, CC, BCC, Body are all read/write properties we can set values to.
Once we have associated all the properties we wish to set we can then call the Send Method which actually sends the data.
And we dissassociate the variable to clean up.
Of course, the properties could have just as easily been set to variables, or database fields. If you want to send to everyone in a database, a simple loop could address each email with the variables you desire. For instance, the following code is what drives the mailing list subscribtion on this very site. As you can see, I have the To property set to the variable "subscriberemail" and I have the subscribername, starting off the Message Body.
The CDO object is a nice way to add a little more functionality to your website without adding a component or creating long scripts. Dropping in a mailing list subscription box, or a sign-up sheet can spice up any website.
|
|