The next enhancement to your web application is meant to ease the task of checking daily which contact's birthday it is and use your e-mail client to send a greeting. It will all be done in an automatic manner at the click of a button.
You will have to create a new page in your site's root folder, which will contain the elements that send the e-mail. To create it, select the New option of the File menu, in the Files tab. If the Files tab is not visible, open it from Window -> Files. Give it a suggestive name (e.g. birthday.php). You will later on add a link in the main page, which will point to this one.
Sending the birthday greetings will be done in a semi-automatic manner at first, the page displaying a list of all persons that were born on this day, and allowing you to decide whether to send the e-mail or not. The automatic part is that you'll only have to click one single button to send the greeting to all people in the list.
To start creating the page, open it in Dreamweaver, and continue with this tutorial: you will create the design first, and later on, you'll add the code that does all of the actions.
When creating the basic design, the approach is the same as for the contact or company insert and update pages:
The list of people born on the day the page is being accessed is in fact a dynamic table, as it should retrieve the names from the contacts table. Before using the Dynamic Table command however, you have to create a recordset containing the names.
To create the recordset, follow the instructions below:
In the SQL text area,
enter the following query:
For MySQL:
SELECT *
FROM contact_con
WHERE date_format(birthday_con, '%m%d') = date_format(now(), '%m%d')
For Microsoft Access:
SELECT *
FROM contact_con
WHERE birthday_con = Date()
Note: Microsoft Access uses the same date format as your operating
system to store date values.
For Microsoft SQL Server:
SELECT *
FROM dbo.contact_con
WHERE DAY(dbo.contact_con.birthday_con) = DATEPART(DAY,GETDATE())
and MONTH(dbo.contact_con.birthday_con) = DATEPART(MONTH,GETDATE()).
For PostgreSQL:
SELECT *
FROM contact_con
WHERE birthday_con = NOW()

After having created the recordset, you can create the listing of its
content, with the use of a dynamic table. To add a dynamic table, click
on its button in the Application tab of
the Insert bar. Configure it to display
entries from the recordset created earlier, rsContacts,
and to display all records. Also, set the table border, cell spacing and
padding to 0. Clicking on OK will add the
dynamic table into the page.

At this point, a table with all data concerning the contacts has been added in the last page paragraph. Not all of the entries are useful, or meaningful, as only the actual contact name is of interest. Therefore, delete all table columns except the name_con one.
For the remaining column, change the name_con static text into a more understandable one: "Name". Also, set the cell as having the header property, from the Property inspector.
Now your page should look like this:

Next comes the switch that will start the mail sending operation: an HTML form button. Place one in a new paragraph below the dynamic table. When asked if a form tag should be added, answer Yes. To make the button more intuitive, replace the Submit label with: "Send birthday greetings". Leave the button's name as is, "Submit".
The mail sending is implemented through the use of one of MX Kollection 3's trigger: the Send E-mail to Recipients from Recordset. However, as any trigger, it needs a transaction on page. As there is no need to add, update or delete anything, the only one that will suit this purpose is the custom transaction. The custom transaction allows you to define the fields to use, and the SQL which will use it. Also, you can just use it as a placeholder, with no SQL operation at all.
Add a Custom Transaction to the page, by clicking on the Plus (+) button of the Server Behaviors tab, and selecting MX Kollection -> Forms ->Advanced -> Custom Transaction. Configure it as follows:

Now that a transaction exists on the page, you can also add triggers that register to it, as the Send E-mail trigger, for instance. Therefore, you can finally complete the last action in this tutorial - apply the Send E-mail to Recipients from Recordset trigger:


Note: If using the ASP VBScript server model you must configure the E-mail server settings in the Control Panel. You must fill in the server address (or name), the port (by default it is 25), the user name and the password. Optionally, you can also set the default sender field.
This was the last step to create the birthday greetings page. You can now save, upload and test it. If no names appear in the list, it may be due to the fact that no contacts in your table are born on this day. Either try again another day, or enter a contact whose birthday is today.
When one of the contacts checks his mail, he will have a pleasant surprise:

Note: When using the Send
E-mail to Recipients from Recordset server behavior to send messages
to a large number of recipients, make sure the value of the max_execution_time
variable in your php.ini configuration file
is sufficiently large to support the execution of the code. Sending many
e-mail messages might take longer than the default setting, depending
on your server configuration and specifications. If you encounter an error
similar to the following
Fatal error: Maximum execution time of 30 seconds exceeded in c:\server\site\includes\common\lib\email\Pear\Net\Socket.php
on line 241
please increase the value of the max_execution_time variable in php.ini, or contact your network administrator.