User Guide

Handling POP Mail 313
Note that 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 attachments with messages
When you use the cfpop tag with action="getAll", and use the attachmentpath
attribute to specify the directory in which to store attachements, ColdFusion gets
any attachment files from the POP server and puts them in the specified directory. It
also returns two additional columns:
attachments Contains a tab-separated list of all attachment names.
attachmentfiles Contains a tab-separated list of the locations of the
attachment files. Use the
cffile tag to delete these temporary files.
You must make sure that the
attachmentpath directory exists before you use the
cfpop tag to get attachments. ColdFusion generates an error if it tries to write an
attachment file to a nonexistent directory.
Not all messages have attachments. If a message has no attachments, attachments
and
attachmentfiles are empty strings.
To retrieve all parts of a message, including attachments:
1 Create a new file in ColdFusion Studio.
2 Modify the file so that it appears as follows:
<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=#username#
password=#password#
action="GetAll"
attachmentpath="c:\temp\attachments"
name="Sample">
<cfoutput query="Sample">
MessageNumber: #HTMLEditFormat(Sample.MessageNumber)# <br>
To: #HTMLEditFormat(Sample.to)# <br>
From: #HTMLEditFormat(Sample.from)# <br>
Subject: #HTMLEditFormat(Sample.subject)# <br>
Date: #HTMLEditFormat(Sample.date)# <br>
Cc: #HTMLEditFormat(Sample.cc)# <br>
ReplyTo: #HTMLEditFormat(Sample.ReplyTo)# <br>
Attachments: #HTMLEditFormat(Sample.Attachments)# <br>
Attachment Files: #HTMLEditFormat(Sample.AttachmentFiles)# <br>