How to 1) sort outlook email messages by date order and 2) filter by outlook category

Hey, I have two questions regarding email automation, grateful if someone in this community could share their expertise…

  1. how to sort a list of Outlook email messages in ascending date order (i.e. emails received furthest in the past/oldest date) at the top of the list)?

  2. how to filter outlook mail messages by category - for instance, I am trying to get only mail messages that are not categorised already (e.g. “Business” or “Personal” etc.) then assign these uncategorised messages to a category, (e.g. Business)


let me know if you have got a solution. i am also looking out for this

@charlieAJ47 @lawanyaram

try the below query in Assign Activity for sorting mail according to received time

MailmessgaseList_varible = MailmessgaseList_varible.OrderBy(Function(x) x.Headers("date")).tolist

Hope it works :slight_smile:


hi Ranjith

thanks for your response. we were able to sort mails after receiving all of them. But the issue was in multi robot scenario we cannot mark all mails as Read. WE wanted to pick onlu one at atime.
we have solved it by assigning sub folders in mail box and then marking mails as read after processing it

1 Like

Hi @lawanyaram,
Try this
"[ReceivedTime] >= '12/02/2018' AND [ReceivedTime] <= '12/02/2018 23:59:59'"
For this scenario in properties assing TOP 1and make it as read.


1 Like

Hey @charlieAJ47,
This may not be the exact same thing that you are trying to do, but using IMAP I was trying to retrieve only unread messages of my inbox.

BUT I was getting all of the messages back from other tabs like “Promotions”, “Social” etc.

What I had to do was specify the Host >> MailFolder setting in UI Path. Here’s a screenshot to show you what it looks like:


Hope that helps! :smile:

Any lead on this? I got similar scenario and now I’m stuck.