User Guide

Table Of Contents
986 Chapter 39: Sending and Receiving E-Mail
To retrieve only the message header:
1.
Create a ColdFusion page with the following content:
<html>
<head>
<title>POP Mail Message Header Example</title>
</head>
<body>
<h2>This example retrieves message header information:</h2>
<cfpop server="mail.company.com"
username=#myusername#
password=#mypassword#
action="GetHeaderOnly"
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><br>
</cfoutput>
</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_only.cfm in the myapps directory under your web_root and view it in
your web browser:
This code retrieves the message headers and stores them in a
cfpop record set called Sample.
For more information about working with record set data, see Chapter 22, “Using Query of
Queries,” on page 489.
The ColdFusion function
HTMLEditFormat replaces characters that have meaning in HTML,
such as the less than (<) and greater than (>) signs that can surround detailed e-mail address
information, with escaped characters such as
&lt; and &gt;.
In addition, you can process the date returned by
cfpop with ParseDateTime, which accepts an
argument for converting POP date/time objects into a CFML date-time object.
You can reference any of these columns in a
cfoutput tag, as the following example shows:
<cfoutput>
#ParseDateTime(queryname.date, "POP")#
#HTMLCodeFormat(queryname.from)#