
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>
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...