Get Outlook Mail Messages - retrieve lots of mails more than 1000 issue

I am trying to make robot to get all mails in public folder but this public folder contains more than 1600 mails first Get outlook mail messages was returned an error “time out” then after making time out time “9 min” it gives me now this error “Get Outlook Mail Messages: Specified cast is not valid.” any idea to solve this issue
1- if i make top like 30 or 40 its working fine but i need to retrieve all mails in this public folder

@mahmoud.zaky - can you revert to default values for OrderByDate & Top properties and try again.

For performance and reliability reasons maybe it would make more sense to get them in chunks of, say, 100 and add them to a queue…then have the bot work out of the queue.

i made that but still the same can not retrieve all mails.

did you mean to get only 100 then get another 100 till the end of emails ?

Loop with a do while. Get 100, or 50, or some reasonable number and put them into a queue. The loop keeps getting 100, or 50, or whatever, and putting them into a queue until there are no more emails to get.

Get 50 emails
For each email
add to queue
check for another email, if there is one set moreEmails to true else set it to false
WHILE moreEmails

thanks for your reply and fast response but can you make a sample work follow as i can not figure out how to implement it.

i know how to use for each and do while i am talking about the condition where can i make bot to get the first 30 mail then loop to take the next 30 ?

1 Like

Hi @mahmoud.zaky,

Use flowchart

Get outlook mail message - Top=30

Condition mailmessage.count<>0

For each
Do your process
Move mail to other folder
(Link to the get outlook mail message)

The last statement inside the loop should be a get emails. The condition for the Do While should be myEmailsVar.Count > 0