Get IMAP email order

Hi All,

Unsure if anyone experienced the same, basically I am trying to read the emails from Gmail with Get IMAP emails activity.

Then I get the following two issues, which I have search the forum, google it and try few things but none seems work.

  1. Get email from one of the email folder - there are at least 15 emails in the folder, but I am unable to get any emails from the folder, did a email count and it return 0, tried same email account with different email folder, it return correct results.

  2. After get IMAP email activity, used for each loop to print the email subject and see if it’s same order as seem on Gmail, but it’s not. I need the bot to get the latest email first to the oldest email. e.g email received 19th Aug 2019, 18th Aug 2019 then 17th Aug 2019 and so on, but when I print it out in the for each loop it doesn’t show in order, it looks like 15th Aug 2019 , 19th Aug 2019, 18th Aug 2019, 12th Aug 2019 then 15th Aug 2019 and …

Tried assigned the email list with mailList.OrderByDescending(Function(x) x.Headers(“date”)).ToList before for each loop but still the same issue.

Appreciate any feedback or solutions that anyone can provide.

Kind regards,


Hi Greetings…!

Please use the below sorting function in assign.

mailMessages.OrderBy(Function(x) DateTime.Parse(x.Headers(“Date”).ToString)).ToList


1 Like

Hi @kadiravan_kalidoss,

Thank you very much, it is working now.

Much appreciate.


1 Like

Awesome that it worked! Cheers :grinning:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.