Administrator Recipe: Mail Log

The Mail Log page displays details of the summary record selected in the just-completed Mailbox page. All information including the message and the list of recipients is included. A recordset is created from the MailMerge table by applying the requested record's ID as a filter.

Step 1: Implement Mail Log Design

A simple layout is all that's needed for this recipe. Here all the data fields are bound to the page as text elements, including the message body and BCC fields.

  1. Create a page from the File > New dialog or by deriving a page from a template.

    graphics/book.gif In the MailMerge folder, find the folder for your server model and open the maillog page.

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

    graphics/book.gif From the Snippets panel, drag the Recipes > MailMerge > Wireframes > Mail Log - Wireframe snippet into the Content editable region.

  3. Add labels for the following eight data fields: Email Type, Email Priority, From, To, CC, Subject, Body, and BCC.

    graphics/book.gif Place your cursor in the row below the words MAIL LOG and insert the Recipes > MailMerge > ContentTables > Mail Log - Content Table snippet [r8-10].


    Figure r8-10.

    graphics/10fig10.jpg


  4. Save your page.

Note

Alternatively, you could use a text area form element to hold the message body. The data is bound to the form field in the same drag-and-drop manner; however, the text would be displayed in a set area where scrollbars are employed as needed.


Step 2: Add Database Components

In this step, we'll take the EmailID passed as a URL parameter in the previous page and use it to filter our recordset. The MailBox data table serves as the basis for our recordset.

PHP users will need to follow up with some custom code to simulate the view used here.

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

  2. In the simple Recordset dialog, enter an appropriate name.

    graphics/book.gif Enter Maillog in the Name field.

  3. Select the desired data source connection.

    graphics/book.gif Choose Recipes from the Connection (Data Source) list.

  4. Choose the needed table.

    graphics/book.gif From the Tables list, select MailBox (mailbox for PHP).

  5. Leave the Columns option set to All.

  6. In the Filter area of the Recordset dialog, set the four Filter list elements like this:

    graphics/577fig01.gif

  7. Leave the Sort option blank and click OK to close the dialog.

PHP developers need to insert a little custom code to create the view programatically.

  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:

    graphics/book.gif From the Snippets panel, insert the Recipes > MailMerge > CustomCode_PHP > MailMerge - Create Temporary Table snippet.

    graphics/php.gif

    [View full width]

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

  2. Save your page when you're done.

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

Step 3: Data Binding Process

Our last step for this recipe and the MailMerge application is a drag-and-drop. With the recordset defined, all we need to do is insert data fields from the Bindings panel onto the page.

  1. From the Bindings panel, expand the Employees recordset.

  2. Place the desired data source fields onto the page:

    graphics/book.gif Drag the MailTypeText field next to the Email Type label.

    Drag the MailPriorityText field next to the Email Priority label.

    Drag the EmailFrom field next to the From label.

    Drag the EmailTo field next to the To label.

    Drag the EmailCC field next to the CC label.

    Drag the EmailSubject field next to the Subject label.

    Drag the EmailBody field to the line below the Body label.

    Drag the EmailBCC field in the line below the BCC (Mail Merge Email List) label.

  3. Save your page [r8-11].


    Figure r8-11.

    graphics/10fig11.jpg


The application is now complete and ready for testing and deployment. Testing a mass emailing application is bit tricky: you want to make sure everything is working properly, but you don't want to annoy your co-workers with too many trial messages. Begin your initial testing by targeting yourself and one or two others on your staff. After you're sure the basic email application is sound, address a larger group, but don't use a mission-critical message. After a few test mailings, check the mail log page and make sure you're getting all the data you need. Remember, these recipes are only a starting point for your own customization and application



Macromedia Dreamweaver MX 2004 Web Application Recipes
Macromedia Dreamweaver MX 2004 Web Application Recipes
ISBN: 0735713200
EAN: 2147483647
Year: 2003
Pages: 131

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