Administrator Recipe: Mailbox


Want to see what email messages have been sent? Check your mailbox! The mailbox page displays a summary of all the messages previously emailed and provides a link for more detail. Summary fields include the email subject, the number of recipients listed, and the email type (HTML or plain text).

As you saw when constructing the Send Mail page in the previous recipe, information about an email is stored in the MailMerge table. The recordset for the Mailbox page is pulled from a view based on this data table and two others (MailPriority and MailType) used to look up values. The Mailbox recordset is designed to display the newest addition first.

Step 1: Implement Mailbox Design

The Mailbox application requirements are straightforward. All that is needed is a basic table to hold the summary items. Navigation to the detail page is handled by attaching a link to one of the data fields.

1.

Create a page for this recipe, from the File > New dialog or by using a template.

In the MailMerge folder, locate the folder for your server model and open the mailbox page.

2.

In the content area of your page, create a header for the page and an area for the email summary items.

From the Snippets panel, drag the Recipes > MailMerge > Wireframes > Mailbox - Wireframe snippet into the Content editable region.

3.

Add labels for three data fields: Sent Items, Recipients, and Email Type.

Place your cursor in the row below the word MAILBOX and insert the Recipes > MailMerge > ContentTables > Mailbox Sent Items - Content Table snippet [r7-6].

r7-6.


Step 2: Add Database Component

The recordset the MailBox application uses is based on a SQL view that combines three tables: MailMerge, MailPriority, and MailType. Although the SQL statement to construct the view might seem somewhat complex, the concept is simple. The basic data is coming from the MailMerge table; both MailPriority and MailType are used to look up text names for numeric values.

[View full width]

SELECT MailMerge.*, MailPriority.MailPriorityText, MailType.MailTypeText FROM (MailMerge INNER JOIN MailPriority ON MailMerge.EmailPriority = MailPriority .MailPriorityPassed)INNER JOIN MailType ON MailMerge.EmailFormat = MailType.MailTypePassed;

As we've seen before, because MySQL does not support views, PHP coders must also add a custom code snippet after creating the recordset that populates the temporary table MailBox.

1.

From the Bindings panel, choose Add (+) and select Recordset (Query).

2.

In the simple Recordset dialog, enter an appropriate name.

Enter MailBox in the Name field.

3.

Select the data source connection.

Choose Recipes from the Connection (Data Source) list.

4.

Choose the needed table.

From the Tables list, select MailBox (mailbox for PHP).

5.

Leave the Columns option set to All.

6.

Make sure the Filter is set to None.

7.

Set the Sort option to show the latest record first.

Choose EmailID from the Sort list and select Descending from the accompanying field [r7-7].

r7-7.


8.

Click OK to close the dialog.

9.

Save the page after the recordset is inserted.

For PHP

The following steps are for PHP users only:

1.

In Code view, move to the top of the page, place your cursor after the PHP connection line that starts <?php require_once, and insert the following code:

From the Snippets panel, insert the Recipes > MailMerge > CustomCode_PHP > Mailbox - Create Temporary Table snippet.

[View full width]

<?php mysql_select_db($database_Recipes, $Recipes); $sql = "DELETE FROM mailbox"; @mysql_query($sql,$Recipes); $sql = "INSERT INTO mailbox SELECT mailmerge.*, mailpriority.MailPriorityText, mailtype .MailTypeText FROM (mailmerge INNER JOIN mailpriority ON mailmerge .EmailPriority = mailpriority.MailPriorityPassed) INNER JOIN mailtype ON mailmerge.EmailFormat = mailtype .MailTypePassed"; @mysql_query($sql,$Recipes); ?>


This code simulates an Access view and prepopulates the Mailbox table before the recordset information is retrieved.

2.

When you're done, save your page.

Step 3: Data Binding Process

In this step, we'll bring the data fields defined in the MailBox recordset onto the page.

1.

From the Bindings panel, expand the MailBox recordset.

2.

Place the data source fields onto the page:

Drag the EmailSubject field under the Sent Items column.

 

Drag the EmailSize field under the Recipients column.

 

Drag the MailTypeText field under the Email Type column.


3.

Save your page [r7-8].

r7-8.


Step 4: Add Link to Subject Dynamic Text

In concept, this page is referred to as a "master" page because it shows a summary of records. Typically, some element on the master page serves as a link to the detail page, which allows the user to drill down to get more specific information about a given record. On this page, we'll use the email subject data field (inserted in the previous step) as our link; this link will call the final page in our Mail Merge application, mail_log, and pass the record's ID as a parameter.

1.

Select the EmailSubject data field on the page.

2.

In the Property inspector, select the folder icon next to the Link field to open the Select File dialog.

3.

In the Select File dialog, select Parameters to begin the process of attaching a name/value pair to the URL.

4.

In the Parameters dialog, choose Add (+) and enter the name of the variable you want to pass.

Enter ID in the Name column.

5.

Insert the value you want to attach to the link.

Click the lightning bolt icon to open the Dynamic Data dialog, and select EmailID from the MailBox recordset. Click OK to close the Dynamic Data dialog.

6.

Click OK to close the Parameters dialog.

7.

Select the file you want to link to.

Select the mail_log page for your server model.

8.

Click OK to close the Select File dialog.

Step 5: Add Repeat Region

We'll finish off the MailBox application by applying a Repeat Region server behavior to the dynamic content.

1.

Select any of the dynamic data fields inserted in the MailBox content area.

2.

From the Tag Selector, choose the table row tag.

Select the <tr> tag from the Tag Selector.

3.

From the Server Behaviors panel, choose Add (+) and select Repeat Region.

4.

In the Repeat Region dialog, choose the recordset.

Choose MailBox from the Recordset list.

5.

Set the Show option to display the number of records you'd like.

Choose Show All Records.

6.

Click OK when you're done and save your page.

A quick check of Live Data view should give you a clear idea of how the page will look [r7-9].

r7-9.





Macromedia Dreamweaver 8 Recipes
Macromedia Dreamweaver 8 Recipes
ISBN: 0321393910
EAN: 2147483647
Year: 2003
Pages: 121

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net