Get the oldest mails first from outlook using UiPath
We use outlook for automating any business process because of two main reasons:
- We can receive inputs for automating that process.
- Sending the reports to business users or the error reports of the processes which are automated.
So, while taking the input emails from the outlook to process it is generally based on the Last in First Out method.
But when we talk about automating a process we will look at the SLA and the action time of the bot to process that email request.
Let’s see the practical implementation of getting the oldest mails first from outlook UiPath:
Step1: Drag and Drop a Get Outlook Mail Message Activity and set the properties as shown below:
This is the same thing we usually do to get all the outlook mails from Inbox.
Here:
- Int32.MaxValue- Get’s all the emails in your outlook inbox.
- MarkAsRead- It will make all the mails as read.
- OnlyUnreadMessages- It will get only mails that are unread.
- Messages- It will store all the mail messages in a List of mail messages.
- MailFolder- Provide the folder name from where it needs to get the mails from.
Step2: Now we have a list of mail messages. Drag and Drop a For each activity and set the properties as shown below:
Here:
We are resetting the order of the mail messages based on date.
Which will get the oldest mail first and the new mail last.
Note:
Make sure change the Type Argument to System.Net.Mail.MailMessage.
This is how we can get the oldest mails from outlook using UiPath.