Get subsequent emails / pagination in Outlook

I am trying to fetch emails from a shared mailbox with the end users. Since the users might accidentally open an email meant for the bot, I am unable to limit by the usual method (fetching unread emails only and avoid reprocessing them by marking as read), nor move processed emails to another folder.

How do I get the subsequent N number of emails? The “Top” option of “Get Outlook Mail Messages” activity only returns the same list of emails.

Thank you.

Hi @shawnteoh

Does this happen even if you have more emails added? What Studio version? And what UiPath.Mail.Activities pack version?


Hi @ovi,

If there are more emails, “Top” will include the newer emails. Not making a bug report here, understand that is the intended behaviour.

Putting my original question in context:
Let’s say there are 50 emails if I filter by today, but if “Top” is specified at 30 for performance considerations, how do I get the remaining 20 emails if I am unable to determine by read/unread?

Thank you.

1 Like

I get it now. And my thought is that you can’t :frowning: if you only retrieve the Top 30.

Isn’t there anything in the email subject/body that people would know not to read?

Or would it show your wf a lot if you take them all and extract the data the Robot needs even if the human has read the email (I assume that read does not mean that they actually did something with the attachment in the email - for example).

I’m just throwing my thoughts here, I have to think more of this one.

Hi @shawnteoh

Sorry for the post, I should have read more carefully that moving to another folder is not a valid option. Unless, of course, you could set a server-side forward to a separate mailbox for the bot.

However, I still think that you should the copy-an-email-on-arrival method together with locking the folder through permissions.

One way would be to set a rule within Outlook to automatically copy an email to a different folder upon arrival. You would then reduce the chance that someone opened the copy of the email in that folder.
There is also some permission settings for folders, so maybe you could even lock a specific folder in the mailbox exclusively for the bot.

This has an obvious disadvantage of only running the rule when your Outlook is opened (unless there is a way to make it a server side rule).

Alternatively, you could forward it to a different mailbox all together that would be meant only for the bot.

1 Like