Copy link to clipboard
Copied
Hi All! Is there a trick for sorting the email messages by newest first instead of oldest first? I have the CFPOP working fine - I just want to only pull out the most recent 35 or so.
<cfpop action="getheaderonly"
name="qGetMessages" startrow="1" maxrows="35"
server="#Pop_Server#"
username="#Pop_Username#"
password="#pop_password#">
Do I need another query in addition to this one? Any ideas are much appreciated.
Copy link to clipboard
Copied
I guess this have something to with your mail server. I use cfpop on my mail server and it sends me the most resent mails first. But in your case, if the mail server sends the oldest mails first then you may have to get everything first and use query of query for the sorting.
- Sam
Copy link to clipboard
Copied
Did you find the solution to reorder from the most recent to the oldest ?
I am looking for an answer to this .
Thanks, Pierre.
Copy link to clipboard
Copied
CFPOP creates a query object result. You could try using Query of Queries to query that result to get the order you desire.
References:
"Using Query of Queries"
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7bb8.html
Copy link to clipboard
Copied
I already tried this, query of query,
but I get an error,
i think it does not consider the CFPOP result as a query (GetHeaders).
I used the name of the CFPOP as the query name
<cfquery name="GetHeaders_o" dbtype="query">
select * from GetHeaders
order by date desc
</cfquery>
It does not like "date" , but date is a column of the CFPOP.
I tried to put the column number (as said in the doc)
Then, it is 6 for date.
<cfquery name="GetHeaders_o" dbtype="query">
select * from GetHeaders
order by 6 desc
</cfquery>
No error, but the date order is not good. (time order)
any other idea ?
Thanks for help.
Pierre.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks, with [ ] it does work.
So I first need to cfpop all messages, (which can be long process)
Then reorder by date
Then display headers from 1 to 10 ,
Then next 10, etc..
If I could order by date at 1st process cfpop, I could ask for only the 10 first.
and the process will take less time.
Ast it is now, the 1st step retrieve all mails, which is long.
Thanks for help.
Pierre.
Copy link to clipboard
Copied
You might use the getHeaderOnly option to limit the size of results in your query. Sort those results, get the UID values for the messages you are interested in. Then create a second CFPOP connection using UID attribute to only get the ten messages you want.
Copy link to clipboard
Copied
Yes , right,
But I wanted to know if messages have attached files. (when listing headers)
And to know this, I must use the "getall" option, without attachmentpath,
then attachmentfiles are not loaded.
And the variable "attachments" says if attachments exist (if not empty).
So I keep the load of "body" , which takes more time, true.
i will use it like this, and see if too much long or acceptable.
thanks for your participation.