Read outlook mails from oldest mail (first in first read)

Hi,
I want to read emails(only unread) in outlook from oldest entry (oldest mail first). So if I have 8 unread mails in outlook, I will start from the last 8th one and then read one by one till 1st. But in my get outlook mail activity, it should always be 10 (in Top). Not more and not less.
I tried reverse method, looping using counter etc. The problem is , if the unread mails are more than 10(as specifiled in Top option of get mails activity), it is not working. It is working fine if the number of unread mails is equal to the mails specified. Please share me a xaml file. its very urgent

@debashishforyou,

If you want you can increase that value in ‘Top’ property.

Hi lakshman,

Thanks for the response. My problem is that the bot will run per schedule in orchestrator(2 hrs interval) and I can`t have more than 10 mails per schedule (and it is from config file) so that the schedule does not breaches. So, max mails to read (Top) can be 10 and not more than that.

@debashishforyou,

For suppose, it is more than 10 unread mails. In this case, Is it reading 10 mails or not reading single mail also ?

It is reading only 10 unread mails

@debashishforyou,

Because you specified ‘Top’ as 10. That’s why its reading top 10 unread mails only. Here, what is your problem ?

i want to read reverse 10

@debashishforyou

Follow the below steps

  1. Take the count of number of emails.
  2. Use a While condition N>=1
  3. Inside the while loop use an assign activity and decrement the count N=N-1
  4. So N represents the last mail or oldest email and now you can extract body, subject and from,to from the oldest to newest email address.

Hi @debashishforyou,

1.Initially create and new mail folder manually and see that there are no unread mails.
2.Then read unread mails in Inbox from the outlook but do not tick MARK AS READ Property.
3.And sort the mails based on date i.e using VList_Emails.OrderBy(Function(x) DateTime.Parse(x.Headers(“Date”).ToString)).ToList and assign it to VList_Emails where VList_Emails is output of Get Outlook Mail Message activity.
4.Now move VList_Emails(0) mail to the created folder.
5.Now again use Get Outlook Mail Message activity and read the mail from the created folder setting the TOP Property to “1” and Tick MARK AS READ Property

Regards
Venkatesh