web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

GetEmails (V3)

(1) ShareShare
ReportReport
Posted on by 5
Hello,
 
Im trying to get the getmails(v3) function to extract several mails used to measure kpis. The only problem im having is im retrieving the mails from a shared inbox distributed in several folders and subfolders. I created an "apply to each loop" that would pass one by one the different folder paths getmails has to go through. Unfortunately its not working, the getmails function can only access the mails in the folder if the folder is selected manually through the small folder icon that lets you navigate. This is a problem when you want to access several folders as it doesn't interpret normal folder routes in the form of text, as said only manually. I show foto to illustrate what i mean by manually.
Captura error POWERAUTOMATE.png
Categories:
I have the same question (0)
  • Verified answer
    Riyaz_riz11 Profile Picture
    4,150 Super User 2026 Season 1 on at
    Hi,
     

    Solution 1: Use Graph API with HTTP Connector

    Replace the Get emails (V3) action with HTTP requests to Microsoft Graph API:


    1. Add HTTP action instead of Get emails (V3)

    2. Method: GET

    3. URI:
      https://graph.microsoft.com/v1.0/users/{shared-mailbox-email}/mailFolders/{folder-id}/messages

    4. Authentication: Use OAuth 2.0 or service principal

    To get folder IDs dynamically:

    https://graph.microsoft.com/v1.0/users/{shared-mailbox-email}/mailFolders?$filter=displayName eq '@{variables('FolderName')}'
     

    Solution 2: Use Outlook REST API

    Similar to Graph API but using Outlook REST endpoints:


    1. HTTP Action Method: GET

    2. URI:
      https://outlook.office.com/api/v2.0/users/{shared-mailbox}/folders/{folder-path}/messages

    3. Headers:

      • Authorization: Bearer {token}

      • Accept: application/json


      •  

    Solution 3: PowerShell Script Approach

    Use the Run PowerShell Script action (if available in your environment):

    powershell
    $folders = @("Folder1/SubFolder1", "Folder2/SubFolder2")
    $results = @()
    
    foreach ($folder in $folders) {
        $emails = Get-MailboxFolderStatistics -Identity "shared@company.com" -FolderScope $folder
        $results += $emails
    }
    
    return $results | ConvertTo-Json
     

    Solution 4: Use Multiple Get Emails Actions

    Create separate Get emails (V3) actions for each folder:


    1. Don't use Apply to each for folder navigation

    2. Create individual Get emails actions for each known folder

    3. Configure each action manually with the specific folder selected

    4. Use Compose actions to combine results
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 976

#2
Valantis Profile Picture

Valantis 863

#3
Haque Profile Picture

Haque 547

Last 30 days Overall leaderboard