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
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
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.
Drag “Get IMAP Mail Messages” activity into the design panel and populate its properties with required fields.
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
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”
Drag “Message Box” activity into the For Each activity and pass the “item.Subject” value into it to display the subject.
Click here to download the Source Code…
Hope it has helped you…