Emails are something that is involved in most of the processes that we automate.
Using UiPath’s default activities we will receive the emails in FIFO order, but what if we want them to be in LIFO?
Let us see how to do that?
new_MailList = old_MailList.OrderBy(Function(x) x.Headers(“date”)).ToList
Note:
1. old_MailList is the default list that you get from the receive mail activities
2. New_MailList is the new list with mails ordered in LIFO
Example
Implementation using UiPath :
Let us implement a workflow that read emails from an account and then provides us the emails in LIFO order, instead of FIFO.
Step 1:
Drag “Get IMAP Mail Messages” activity into the design panel and populate its properties with required fields.
Step 2:
Drag “Assign” activity into the design panel and populate it with an above-mentioned code
example: mails_List.OrderBy(Function(x) x.Headers(“date”)).ToList
Step 3:
Drag “For Each” activity into the design panel and pass the above “newMailList” variable to it and change the type in the properties window to “System.Net.Mail.MailMessage”
Step 4:
Drag “Message Box” activity into the For Each activity and pass the “item.Subject” value into it to display the subject.
Step 5:
Finally!!!
Click here to download the Source Code…
Hope it has helped you…