Readmessage. CFM ColdFusion Help

• The next template you will look at is the readmessage. efm template, because this is the logical second stop for most users: After they view their inbox, they will generally attempt to read their new messages.
Thistemplate simply retrieves the contents of a specified message and displays it along with a menu, as shown in Listing 22.5

Immediately, you will notice how much shorter this template is compared to the Inbox . efm template. That is because far fewer decisions need to be made to display a single message than were needed to display a neatly formatted, functional inbox. Nonetheless, there are still four main parts to this template, as outlined in the following sections.

The readmessage. efm template displays a message, as shown in Figure 22.5.

Line 4

In line 4, you set your token again, just as you did, in the ; nbox. cfIRtemplate. Howevet, unlike the inbox. cfm template, there is no ambiguity about where yOUl’information is coming from: It is being passed in the URL. TherefOre, you, can proceed to build the token directly from the URL parameters without first assigning ~ values to other variables. Indeed, throughout this template and the compose. cflll template, the l!RL parameters are accessed directly.

Lines 9 ,to 10

This is where the CFPOPtag is used to retrieve the message. Notice the use of the GetA 11 value for ‘the ACTION attribute and the use of the MESSAGENUMBERattribute to spedfy the message to be retrieved

Lines 14 to 20

This section of the template displays the menu that appears above
we 225. This menu provides access to all the major functims, including composing, forwarding, and deleting, as well as a quiclc way to retu.m to 1be inbox. All of theIe are fonnecl of links that include the token and, where needecl,\ manage number and an action.

Lines 24 to 34

In this final section of the template file, the messael? itself is Qisplayed. This section makes simple use of the CFOUTPUT tag to display the results rov- returned by the CFPOP query

compose.cfm

The last main template is the compose. cfm template. ‘This template provices three functions:

• Composing new messages
• Replying to messages
• Forwarding messages

These three functions can all be performed by the same template because replyingand forwarding are special cases of composing: Tne composition for  needs to include preset recipients r body tex+when 2 user replies or forwards. After that preset  data is in the message composition form, then works in the same way as COmpOSL’1a.gnew message.

With this in mind, the compose. cfm :look<like Listing 22.6.

Lines 30 to 61

In this section of the template, the actual • es ””fl’ cox; .osition form is displayed. There are only a few small points to note here:
• The token is appended to the URL used L the ACTION attribute of the FORMtag. This ensures that the necessary information is passed along to the send. cfm template, which will send the message.
• The four variables you created in the previous section of the form are used to preset the values of the four form fields

Send.cfm

When a user finishes composing a message and submits the form presented with the compose. cf;- emplate, the contents of the form are posted to the send. cfm template, as shown in Listing 22.7.

delete.cfm

The final template to look at is the de 1ete . efm template, which is invoked when the user clicks the Delete link for a message in either the inbox, or when the user reads a message

Shortcomings of the Application

The application you have just built has considerable functionality. Nonetheless, several shortcomings exist because of the limitations of length and complexity imposed by presenting the information in a book. These include the following: No error handling If the user enters the wrong username, password, or server name, the inbox will fail to display, and instead the, user will see a ColdFusion error. No security The user’s password is passed between templates as a URL parameter and in plain text. If used on the Internet, this application exposes the user’s password to theft.

No attachment handling The application fails to inform users if messages have attachments and, if they do, to provide a method for retrieving the attachments. No blind copies The application fails to provide a method to ere ‘~blind carbon copies (bee) of outgoing messages. This is a shortcoming of the CFMf L tag. No safety net When a user clicks a link to delete a message, the message is deleted. There is no second chance for the user to confirm or reject the decisions to delete the message.
Even with these shortcomings, learning how this 3fplication works provides a solid grounding in the e-mail functionality of ColdFusion. If you want to expand the scope of your e-mail-related skills, try addressing some of the shortcomings in the preceding list.

Where Do We’Go from Here?

In the next chapter, you will look at another major Internet protocol: Hypertext Transfer Protocol. By using CFHTIP to access the HITP, you can use ColdFusion to retrieve URLs from the World Wide Web, and then work with the resulting content in ColdFusion. You can also use CFHTIP to post information to URLs (for instance, automatically submitting information to forms without user intervention). In addition to the CFHTIP tag, you will look at the CFHTIPPARAM tag, which is used to specify parameters used then posting with the CFHTIP tag.

Posted on November 14, 2015 in Reading Mail

Share the Story

Back to Top
Share This