How to filter emails from oldest to newest in gmail?

I would like to know if it is possible to perform email filtering using the For Each Email activity with Gmail?

I created a process that performs the extraction of emails in the inbox on a Gmail address, but by default the order of extraction is always from the most recent emails to the oldest emails and I would like to reverse that order.

You could reverse the list using the Reverse method:

In Studio, you would use the Invoke Method activity and pass the list as a parameter.

I would like to know if there is a way to invert the oldest emails to the most recent ones using the date filter of the For Each mail activity

@vinicius.botelho

Welcome back to our UiPath community.

  1. Let’s say your mail list is mailList.

  2. And then try below expression to reverse the mailList as below.

       mailList = mailList.Reverse.ToArray
    
  3. And then use For Each loop activity to retrieve one by one email.

       For Each item in mailList
    

In this way you can get oldest emails first.

2 Likes

List_of_Mails.Orderby(Function(M) M)

Hi @lakshman

I used the reverse method, but when it is executed, it is not respecting the indicated limitation of 5 emails or any other numbering

image

@vinicius.botelho

Are you getting any error ?

@lakshman
In fact, the method is working. It is performing order reversal by extracting the emails from oldest to newest. But it is not respecting the email limit I set in the filtering and it is extracting more than 100 emails

@vinicius.botelho

You mean For Each loop iterating more than 5 times or Email activity reading around 100 emails ?

@lakshman

I limited it to reading 5 emails, but if I limit this number to more or less, the same problem will occur as reading more than 100 emails. When I remove the Reverse method, this problem does not happen.

Hello everybody

I found a solution to this email throttling problem. Before using the Reverse method, I used the Take method and entered the number of emails I want to extract. So I was able to extract the emails from oldest to newest.

Thank you all!

image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.