8 Replies Latest reply on Nov 9, 2011 8:43 AM by plarts

    CFPOP Sort Order


      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"


      Do I need another query in addition to this one?  Any ideas are much appreciated.

        • 1. Re: CFPOP Sort Order
          Saman Level 1

          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

          • 2. Re: CFPOP Sort Order
            plarts Level 1

            Did you find the solution to reorder from the most recent to the oldest ?

            I am looking for an answer to this .

            Thanks, Pierre.

            • 3. Re: CFPOP Sort Order
              JR "Bob" Dobbs Level 4

              CFPOP creates a query object result.  You could try using Query of Queries to query that result to get the order you desire.




              "Using Query of Queries"

              http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24 -7bb8.html

              • 4. Re: CFPOP Sort Order
                plarts Level 1

                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



                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


                No error, but the date order is not good. (time order)


                any other idea ?

                Thanks for help.


                • 5. Re: CFPOP Sort Order
                  JR "Bob" Dobbs Level 4

                  I suspect that you will need to escape the column name "date" which is a reserved word as .  Add square braces around the keyword.  Keywords and how to escape them are contained in the "Escaping reserved keywords" section of the Query of Queries documentation.

                  • 6. Re: CFPOP Sort Order
                    plarts Level 1

                    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.


                    • 7. Re: CFPOP Sort Order
                      JR "Bob" Dobbs Level 4

                      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.

                      • 8. Re: CFPOP Sort Order
                        plarts Level 1

                        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.