“Is there a way to overcome the limit of 25 emails that are returned by the ‘Get emails (V3)’ Power Automate action?”
If you extract emails with the ‘Get emails’ action, you’ll notice the ‘Top’ field. This field defines how many emails it’ll retrieve, and the maximum is 25 emails. The action doesn’t allow you to define any higher number, you’ll get 25 emails and that’s it.
But that’s a small limit considering how many emails some people send and receive daily. There can be a hundred, or multiple hundreds of emails waiting for processing.
How do you get all those emails?
Get the emails directly via Graph API
While the ‘Get emails’ action is limited, there’s another way how to get emails from your mailbox – via the Microsoft Graph API. You can imagine it as the ultimate interface to communicate with the Microsoft 365 platform, and although it can get quite complicated for some operations, extracting emails is easy.
The action you’re looking for is the Office 365 Outlook action ‘Send an HTTP request’.
This action allows you to send some requests to Graph API, and retrieving emails is one of them.
Get emails from a specific folder
When getting emails from a specific folder, e.g. Inbox, you’ll always need the folder id.
https://graph.microsoft.com/v1.0/me/mailFolders/<folderId>/messages
The easiest way to get the folder id is similar to getting id of a folder in a shared mailbox. Add the ‘Get emails’ action, select the folder, and go to ‘Peek code’.
You’ll see the parameter ‘folderPath’ starting with Id:: and following with the folder id.
That’s the ID you need, it might look as below:
AQMkADE3OTNhNGI1LTYyYjctNDY4OS0543210ZDQ1ODcyMDI1OAAuAAADh0B4vZMJRUuk0KeEgj1abcde_HTm2u9F_0iDdSSR05BZTwABHOBFygAAAA==
Take it and use it instead of the folder name in the HTTP request.
https://graph.microsoft.com/v1.0/me/mailFolders/AQMkADE3OTNhNGI1LTYyYjctNDY4OS0543210ZDQ1ODcyMDI1OAAuAAADh0B4vZMJRUuk0KeEgj1abcde_HTm2u9F_0iDdSSR05BZTwABHOBFygAAAA==/messages
Such HTTP request will give you the emails in the folder including all their data. Which can be a bit more information than you need and it can take a while before it loads everything. Adding the $select parameter will reduce each email information only to some properties, e.g. the sender and the subject in addition to the default email id.
https://graph.microsoft.com/v1.0/me/mailFolders/AQMkADE3OTNhNGI1LTYyYjctNDY4OS0543210ZDQ1ODcyMDI1OAAuAAADh0B4vZMJRUuk0KeEgj1abcde_HTm2u9F_0iDdSSR05BZTwABHOBFygAAAA==/messages?$select=sender,subject
The last parameter to add is the number of emails. By default it’ll return 10 emails as the ‘Get emails’, but you can add the ‘top’ parameter to increase the number, e.g. to 100 emails.
https://graph.microsoft.com/v1.0/me/mailFolders('Inbox')/messages?$select=sender,subject&top=100
Summary
It’s possible to get more than 25 emails from a mailbox in Power Automate, but not with the default ‘Get emails’ action. The action has a limitation that you can’t bypass, therefore, you must use another approach. And the approach is to ask for the emails via Graph API. Use the Office 365 Groups action ‘Send an HTTP request’, define which folder it should check, and get as many email as you’d like.
Could you show me the way to get many value is modified in sharepoint and summarized them and send all of new value update to mail outlook in once time.
Hello Tran Dac Huy,
I’m sorry but I don’t see how it’s related to the article.
Hi Tom,
how would you add a filter on the email Subject, e.g. “Order#”, extract those emails with that text in the Subject, and then write the Subject and the email date into a excel table?
Hello Matt,
set the subject filter in the trigger action (https://tomriha.com/search-for-multiple-words-in-the-incoming-email-subject-power-automate/) and then just add a new row in the Excel file.
Hi Tom, rather than retrieve my emails I would like to retrieve emails sent to my team in a shared mailbox.
I guess I would change the reference to ‘me’ in the URL https://graph.microsoft.com/v1.0/me/.
Could I used this method to identify a different mailbox?
Hello Mark,
you should be able to access shared mailbox using the call below:
https://graph.microsoft.com/v1.0/users/{sharedmailboxmailaddress}/messages
source: https://docs.microsoft.com/en-us/answers/questions/80006/shared-mailbox-handling-with-microsoft-graph.html
great posting. But i´m having trouble when submitting the “send an http request”. I have a flow where it gets 25 mails untill now 😉 but after “send an http request” i have the “apply to each” where it should forward an mail if it is less than or equal to -5 days. here it seems my flow breaks when their is more than 25 emails in the subfolder, used the Get-email. The above seems to break the flow preferably because it should select an output and suggests “body” but if i chose this i wont be able to forward the mail with its attachment, guessing here. Can´t seem to figure out which 1 to choose here
Hello Jann,
it’ll offer only the body as the dynamic content, but you can extract any information about the email directly from the output JSON as described here: https://tomriha.com/how-to-get-a-specific-value-from-a-json-object-in-power-automate/. I guess you’ll need the email id to forward the email.
Hello Tom,
Thank you for this post.
I have a question, which parameter does includes attachement ? (Like with get emails trigger)
Thank you for your help
Hello Tom,
I finally succeeded to get all the attachements from my mails by using a second http request in an apply to each loop.
https://graph.microsoft.com/v1.0/me/mailFolders('@{variables(‘ID’)}=’)/messages(‘@{items(‘Apply_to_each’)?[‘ID’]}’)/attachments?
Have a good week-end.
Hello Nasser,
thank you for sharing the solution.
Hey Nasser could you please send me a Screenshot or something else to help me understand what to do?
Hi Tom,
Thanks for the valuable insight. However, I don’t understand how do I make the flow to repeat the request. I thought I don’t have to put a ‘get emails’ command in the flow. If I only put an Add Row into a tabel, it only yields one email. How do I make them loop? I guess the subject, body and other fields of interest have to be brought in via some JSON commands?
Thanks in advance for any help!
Hello Horea,
the HTTP request will return among others an array with the emails, you can get them using the Parse JSON action (https://tomriha.com/where-do-i-get-schema-for-the-parse-json-action-in-power-automate/) that’ll parse the output for you or directly with an expression (https://tomriha.com/how-to-get-a-specific-value-from-a-json-object-in-power-automate/).
After retrieving the desired emails using the API call as described is there a way in power automate to then delete them?
Hello Jamie,
the request will return a JSON with all the emails, you can then extract the array with the emails using the Parse JSON action (https://tomriha.com/where-do-i-get-schema-for-the-parse-json-action-in-power-automate/) or an expression (https://tomriha.com/how-to-get-a-specific-value-from-a-json-object-in-power-automate/), take their IDs and use them to delete the emails.
Hi Tom,
Can we get the same from Online Archive of Outlook shared mailbox? Can you please suggest.
Hello Siddhartha,
I don’t know, my customers never needed this.
Great article! Do you know of a way to extract the email addresses from the sub folders and the sub folders inside that sub folder. For example, Lets POWER Automate/2023 where “2023” is a sub folder under “Lets POWER Automate” sub folder.
Hello Mark,
I’d try to use the subfolder name in the request, e.g. …/mailFolders(‘2023’)/…
Can you do this from a shared email inbox?
Hello cym,
I didn’t try that on a shared mailbox, but I might add it to the list of potential future articles and take a look on it.
you can try to do adding variable initialize as 1 and then do a while until this is 0, and get 25 by 25 records until nothing is coming
Hi, For some reason it didn’t work for me. I’m getting the following error note:
“URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector. Resources: groups.”
What am I missing?
Hello Giora,
there was a change in the action, the functionality was divided into multiple actions depending on the Graph endpoint and also the url is different – I updated the article to use the current one, ‘Send an HTTP request’ from the Office 365 Outlook group of actions.
It looks like the UI for Power Automate was changed and you can no longer see the FolderID, is there a different way to get this to work?
if you toggle the “New Designer” button (top right, just under your initials/picture) off, you get the old view which allows you to get the folder ID as described.
I am using Get Emails v3 from a folder in Inbox. But Get Emails is not picking up the email responses to the original email. any pointers? i didnt want to add Sent Item, since it could bring the system down