Skip to main content
Dani Szwarc
Inspiring
May 7, 2020
Question

CFIMAP action GetAll loop start from latest

  • May 7, 2020
  • 1 reply
  • 655 views

Hello community, hope you are all doing well and safe.

I am running a script to insert all email information within a particular folder to a Database table.

It is working fine but it is starting form the oldest ones instead of the most recent ones.

This is my cfimap block:

 

I am doing 4 emails at the time otherwise the process is slow.

Is there a way to revert the "get all" order, getting the most recenct first?

 

Thank you in advance!

    This topic has been closed for replies.

    1 reply

    WolfShade
    Legend
    May 8, 2020

    Hi, Dani,

     

    CFIMAP returns a query object.. so instead of trying to retrieve newest to oldest, get only the unread emails and loop backwards through the query to process in the order you want.

     

    HTH,

     

    ^ _ ^

     

    (UNTESTED, I've never used CFIMAP, so this is just a guess.)

     

    UPDATE:  Okay, I don't know that it returns a query object.  If it doesn't, you can easily create a query object by iterating the results, and then use that query object sorted by date descending to insert into your database.