UD40 Ultradev Tutorials
Home

Tutorials

Search

Links

Credits

Feedback
Home | Search | Back
Tutorial 4 - A simple mailing list
This tutorial shows how you can easily send emails to a list of email addresses contained in a database using UltraDev. The most obvious use for it is for making a mailing list for your web application.

First let's take a look at the database design. Assuming you have an Access database with a table called 'Login' with the following data:



Fire up UltraDev and create a new document. Create a recordset called rsName (can be any name actually) to select the colum from your database that holds the email addresses.


It is a simple enough SQL statement, as can be seen above. Since we are going to need just the email addresses, using SELECT * and bring in other unnecessary stuff from the database is unwise and a waste of server resources.

Now type in those lines of codes highlighted in yellow by hand in the HTML Source window (hitting F10 will bring you to it):



Of course the code utilises CDONTS (Collaboration Data Objects for WindowsNT Server) to send the mails. Your host would have to install CDONTS on the server if this is going to work, but more often than not CDONTS are installed. There are other mail components like ASPMail and JMail that you can use apart from CDONTS.

You also have to make sure the form button that you are using to get to this page is named as "Submit". If you are using a link to get to this page, remove line 8 and 18 (the If... then and End If) from your code.

Now exit from the HTML Source window (hitting F10 again will do the trick nicely) and go back to the document view and select the entire block of ASP codes you have just added. Apply a Repeat Region Server Behavior from the Server Behaviors pallete to it, and select Show All Records.





What you have to do next is to add a redirect line near the end of the code block just after the Wend line. This is the page you want to show after the mails have been sent, so it can be a page that says something like "All mails have been sent successfully" or something. You can safely delete all the HTML tags in the document (those that appear in blue below) as we will have no use for them. Leaving them there doesn't appear to give any problem either.


One last note: In order to adopt this simple trick to your different needs, what you can do is to modify the recordset creation step early in the tutorial, i.e. by adding various conditions via a WHERE clause to your SQL statement.

No demo | Back


Copyright © 2001, Swee Hoe Ong
All rights reserved.