How to get only the latest email in Exchange mail activity?

I’m using exchange email where I have 2 emails with the same subjects in my inbox

I only want to retrieve the latest one

How to achieve this?

1 Like

@Lahiru.Fernando sir can you help me with this?

In the property panel of the exchange mail activity keep “Top = 1” and check.
And tick mark the OnlyUnreadMessages.


HI @cybzom

Another method would be, once you read the emails, use the << MailVariable >>.headers(“Date”) and get the latest mail from there using a loop

1 Like

I am processing a lot of emails so I cannot keep the top as 1 it is 30 but sometimes when they send updates I must only fetch the latest one

Hi @Lahiru.Fernando

item.headers has only (“name”) and (“index”) can u pls explain in detail or maybe share a flow?


I tried this

mailMessages.OrderBy(Function(x) DateTime.Parse(x.Headers(“Date”).ToString

but this doesn’t seem to be working is there any ohter way sir?

Try this one and see whether it works

1 Like

No sir it’s still fetching both the attachments…

@Palaniyappan sir can u hlp me with dis?

1 Like

So once you fetch the first one, break the loop :slight_smile:


It’s working but this is sorting the date by asending order so old mail is fetched

I have recd a mail at 10:03 and 10:05 but this expression is fetching me the 10:03 one but I need the latest one…

Break condition is working perfectly…

I’m real close to getting the soln kindly help me sir @Lahiru.Fernando

1 Like

usually GET OUTLOOK MAIL ACTIVITY will fetch the latest mail only, but to ensure that once lets refresh the mail box by making some default settings so that we wont miss these sort of even two mins of new mail
For more details of mail refreshing

Cheers @cybzom

1 Like

I’m using exchange mail sir @Palaniyappan

Everything is working well but it’s fetching the old mail when I use the expression given by Lahiru sir

I tried to do reverse but it not working either

That would work for sure buddy but we just need to use a START PROCESS activity that would try to open the application either exchange or outlook, which will eventually refresh the mailbox so that if we place the activity that fetches the mail will obviously fetch the latest one

Cheers @cybzom
do you

1 Like

Sir I am fetching the email via web just using activity (no ui involved) but reverse or distinct is not working with the above provided expression

@Palaniyappan na is there no other way? I want the latest mail only so how to get that?

@Palaniyappan na there is no other choice for this ? If there are multiple subjects of same name it should retrieve the last one… pls help…

I’m retrieving a lot of mail based on some groups but it should only retrieve the last if more than 2-3 unread mail exists…

1 Like

Sorry for the delayed response
is the TOP property set with 1 in the property panel
Cheers @cybzom