Sorting emails based on priority and Received Date

Dear all,

For filtering emails with specific subject, we can add the SQL string in Filter property of GetIOutlookMessages activity.
“@SQL=” & Chr(34) _ & “urn:schemas:httpmail:subject” & Chr(34) _ & " ci_phrasematch ‘question’"’

(Reference : Filtering Items Using a String Comparison | Microsoft Learn)

Is there any way to specify the sorting logic (for prioriry and Received) in SQL string.

Please share your ideas

Thanks in advance.

Hi,

Refer the below post for Outlook Filter Item Query for subject and received time

Refer the below post for reading the mails based on priority

1 Like

Dear @anil5 ,

The above posts which you shared are for filtering the outlook mails. My query is on the sorting of emails by ReceivedDate and priority.

Thanks.

Hi @MariaJosephina,

In get outlook message activity if you filter the mail messages based on received time or priority you can save the mail using save mail activity and the mails will be sorted.

or is it like you have stored your emails already in a particular location and you want to sort them.

My requirement is :
I have 10 unread email in my mail box.
I want to read the oldest email(only 1 mail); mark it as read and do some processing.

On the next execution, it will read the next oldest email and mark it as read and do some processing.

So in order to do this, I will be using GetOutlookMailMessage activity.
By default GetOutlookMailMessage reads the last recieved mail only(I want to change this behaviour to 'Read first received mail).
I want to specify the filter as : Sort the mails by ReceivedDate and priority.

This link might help you.

Hey @MariaJosephina

You can Read only Top 10 Unread Mail Messages By settin Top property to 10 and check OnlyUnreadMessages Property to Check and MarkAsRead as well.

then you can use mailmsgs.OrderBy(function(p) p.Priority).OrderBy(Function(m) m.Headers("date")) with For each Activity to process your items one by one.

If still facing any problem lemme know.

Reference:- OutlookReceivedTimeSort.xaml (7.0 KB)

Regards…!!
Aksh

2 Likes

Yes we can sort it with a seperate fucntion ( mailmsgs.OrderBy(function§ p.Priority).OrderBy(Function(m) m.Headers(“date”))).

I was asking if we can do it using this SQL string : ’ “@SQL=” & Chr(34) _ & “urn:schemas:httpmail:subject” & Chr(34) _ & " ci_phrasematch ‘question’"’
which we use for subject filtering.

(Note : During one execution of the workflow, only one mail should be processed.)

Thanks @aksh1yadav. It’s working fine.

1 Like

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