Deleting messages

Using the cfpop tag to delete a message permanently removes it from the server. By default, retrieved messages remain on the POP mail server. To delete the messages, set the action attribute of the cfpop tag to Delete. Specify use the messagenumber attribute to specify the messages to delete; omit the attribute to delete all the user's messages from the server.

Note: Message numbers are reassigned at the end of every POP mail server communication that contains a delete action. For example, if you retrieve four messages from a POP mail server, the server returns the message numbers 1,2,3,4. If you delete messages 1 and 2 with a single cfpop tag, messages 3 and 4 are assigned message numbers 1 and 2, respectively.

To delete messages:

  1. Create a ColdFusion page with the following content:
    <html>
    <head>
    <title>POP Mail Message Delete Example</title>
    </head>
    
    <body>
    <h2>This example deletes messages:</h2>
    
    <cfpop server="mail.company.com"
    	username=#username#
    	password=#password#
    	action="Delete"
    	messagenumber="1,2,3">
    
    </body>
    </html>
    
  2. Edit the following lines so that they refer to valid values for your POP mail server, username, and password:
    <cfpop server="mail.company.com"
    	username=#username#
    	password=#password#
    
  3. Save the file as message_delete.cfm in the myapps directory under your web_root and view the file in your web browser.
  4. Run the header_only.cfm page that you created to confirm that the messages have been deleted.

    Caution: When you view this page in your web browser, ColdFusion immediately deletes the messages from the POP server.


View comments in LiveDocs