This post is more than 2 years old.
Robert writes in with a question concerning CFPOP:
I have put together a little webail app for my website and for the most part it works pretty good but.... It returns the mail messages in a seemingly random order. Is there a way to order the results?
I could have sworn that I remember CFPOP returning items in order of delivery. In other words, the first message sent to the account would be the first downloaded. The documentation for cfpop does not specify an order, so I probably wouldn't depend on any order.
That being said - don't forget that the result of cfpop is a query. Because of this, you can use query of query to sort the results. You can sort by sender, date, subject, or any other column. Here is a simple example:
<cfpop server="pop.xxx.com" username="..." password="..." action="getHeaderOnly" name="qGetMessages">
<cfquery name="qGetMessages" dbtype="query"> select * from qGetMessages order by date desc </cfquery>