User Guide

Table Of Contents
988 Chapter 39: Sending and Receiving E-Mail
</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=#myusername#
password=#mypassword#
3.
Save the file as header_body.cfm in the myapps directory under your web_root and view it in
your web browser:
This example does not use a CFML function to encode the body contents. As a result, the
browser displays the formatted message as you would normally see it in a mail program that
supports HTML messages.
Retrieving messages and attachments
When you use the
cfpop tag with an attachmentpath attribute to specify the directory in which
to store attachments, ColdFusion retrieves any attachment files from the POP server and saves
them in the specified directory. The
cfpop tag fills the attachmentfiles field with a tab-separated
list of the locations of the attachment files. Use the
cffile tag to delete these temporary files
when they are no longer needed. ColdFusion MX creates the directory if it does not exist.
(ColdFusion MX must have the appropriate rights on the system to create the directory.)
If a message has no attachments, the
attachments and attachmentfiles columns contain
empty strings.
Note: CFML does not provide a way to change the name of a mail attachment returned by cfpop
before it tries to save the file. If the attachment name is invalid for the file system on which ColdFusion
is running, the attachment cannot be saved.
To retrieve all parts of a message, including attachments:
1.
Create a ColdFusion page with the following content:
<html>
<head>
<title>POP Mail Message Attachment Example</title>
</head>
<body>
<h2>This example retrieves message header,
body, and all attachments:</h2>
<cfpop server="mail.company.com"
username=#myusername#
password=#mypassword#
action="GetAll"
attachmentpath="c:\temp\attachments"
name="Sample">
<cfoutput query="Sample">