In this section of the tutorial you will build the site's main page (mail) which displays in a dynamic table article titles and descriptions, and which must be sent by e-mail to recipients retrieved by a recordset.
As for the index and thankyou pages, if you use the files provided in the zip package, they already have content added.
If creating your own pages, follow the next steps to add the same content:
In the index page, type Send article list. Select the text and right-click on it. From the pop-up menu select the Make link option. In the dialog box that opens select the mail file and click on OK. Save the page and upload it to the server.
For the thankyou.htm page, simply add some text (e.g. The mail message has been sent to all selected addresses.). Optionally, you can also add a link to the site index, to make re-sending the messages easier.
Next you will create the site's most important page: mail, which will contain a table with dynamic values, which will send to a list of recipients.
To create this page, follow the next steps:
Open the mail page in Dreamweaver.
First add a recordset that will retrieve all articles from the database. To add a new recordset, click the Plus (+) button from the Bindings tab, and from the pop-up menu select the Recordset (Query) option. The new recordset dialog box will open.
In the dialog box enter the new recordset's name
(rsArticles), select the database connection
defined at the beginning of this tutorial, and the page_pag
table:

Next add a Dynamic table on the page that will
display the data. To add a dynamic table, click its icon in the Application
tab of the Insert panel. In the dialog box that opens, select the rsArticles recordset as source, and set it to display
all records.

From the table added to the page, remove all columns
except the title_pag and description_pag. For the remaining fields, change
the header to Title and Description.
Also set the columns to be headers (check the header option in the property
inspector for both cells):

Save the page and preview it in the browser to
make sure the table really displays the correct articles.

The same list should be displayed in the index page as well, so that you know what the mail message will look like. To achieve this, open the index page in Dreamweaver (if not already opened) and repeat steps 2 through 6. Then save and upload the index to the server.
Now create the recordset that will retrieve the
recipients. To add the recordset click on the Plus
(+) button of the Bindings tab, and
select Recordset (Query). In the dialog
box that opens, enter the recordset name (rsMail),
select the database connection defined at the beginning of this tutorial
and the user_usr table:

Next select the entire table on page (either drag
and drop around it, or click the <table>
tag in the tag inspector:
![]()
Apply the Send Page Section by E-mail server behavior. To access the server behavior, go to the Server Behaviors tab > + > MX Kollection > Send E-mail. Configure the dialog box as follows:
In the From field enter the e-mail address to use for the sender. If you have correctly configured the E-mail settings from the InterAKT Control Panel, you can also use the default sender address (it is filled in by default).
For the To field,
you must use the field retrieved by the rsMail
recordset. To use dynamic data, click on the InterAKT
Dynamic Data icon next to the text field. In the new interface,
select the source recordset (rsMail) and
the field storing the e-mail addresses (email_usr):

Also enter a subject: Our article list.
In the Redirect to page
field you must enter the page to open once the messages have been sent.
You can either type the file name, or click on the Browse
button to select it from the local site structure. Select the thankyou.htm
file.

You also have to set some advanced options. To reach them, click on the Options tab of the User interface.
Since the content to send is HTML (more exactly
a table), and it should look the same for the recipient, select the mail Format to be HTML Text.
Then you can click on OK to apply the server
behavior to the page.

At this point, if you save all site pages, and upload them to the server, you can click on the link situated in the site's index. But only the first address retrieved by the recordset will receive the message, and not all. This happens because the simple use of the field mark-up in the interface does not loop through the recordset entries. To implement this, you will have to manually enter some code.
In Dreamweaver, switch to code view: View > Code. Locate the code section that initializes the tNG_EmailPageSection object.
For PHP, the
code is:
$sectemailObj = new tNG_EmailPageSection();
For ASP, the
code is:
Dim sectemailObj: Set sectemailObj = new tNG_EmailPageSection
For ColdFusion,
the code is:
sectemailObj = Request.tNG_CreateObject("triggers.tNG_EmailPageSection");
sectemailObj.init();
The line that establishes the recipient is the
one containing the call to the setTo function
(eg. $sectemailObj->setTo("{rsMail.email_usr}");).
Cut this line from the page, as it will have to be moved lower in the
code.

Also locate the code line that executes the object
(similar to sectemailObj->Execute() ). Before
this line paste the setTo code you've cut before.
Now you should have the two lines together.
![]()
Next you have to enter the code that will loop through the recordset. The two lines of code shown in the image above must be inside the loop. To implement the recordset looping, you must type the following code:
For PHP:
do {
the two existing lines of code
} while($row_rsArticles = mysql_fetch_assoc($rsArticles))
For ASP, you
also have to declare some variables before the mail sending option (the
block in the image at step 12):
Dim Repeat2__numRows
Dim Repeat2__index
rsMail_numRows = rsMail_numRows + Repeat2__numRows
And the loop code is to be placed lower on the page, surrounding
the lines of code mentioned above
While ((Repeat2__numRows <> 0) AND (NOT rsMail.EOF))
the two existing lines of code go here
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsMail.MoveNext()
Wend
For ColdFusion:
<cfoutput query="rsMail">
the two existing lines of code go here
</cfoutput>
For PHP, the final code looks like the following:
(for the other server models, the code resembles, with only syntax differences):

Once the recordset loop code is added, you can
save the page and upload it to the server. If you access the mail page,
it will send the article table to all users in the recordset. Here's a
sample image taken from the mail Inbox:
