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 Platform Community / Forums / Power Automate / Mapping emails to diff...
Power Automate
Answered

Mapping emails to different people based on folder name

(2) ShareShare
ReportReport
Posted on by 11
Hello,
 
I am creating an automated email notification system to alert members of a team when an item has been modified or created. I have 4 different people who need to be notified when an update has been made but to specific folders. I am currently using PowerAutomate in web browser (Chrome).
 
As an example, I have folders A-G (7).
  • When folder A is updated, Person #1 gets notified.
  • When folder B is updated, Person #2 gets notified.
  • When folder C is updated, Person #3 gets notified.
  • When folder D is updated, Person #1 gets notified.
  • When folder E is updated, Person #2 gets notified.
  • When folder F is updated, Person #3 gets notified
etc etc... Can someone please help explain how I can get this to work? The current flow is functioning as "When an item is created or modified" and then "send an email". As it is currently, it can send 1 email to all of the team members when any of the folders is updated but I would like to personalize it to prevent redundant emails to the rest.
Categories:
I have the same question (0)
  • Verified answer
    Tomac Profile Picture
    4,105 Moderator on at
       
     
     
    The simplest way to do this, without much coding but still able to be updated easily, is to use the following Flow:
     
     
     
     
     
     
    Here's a breakdown, action by action.
     
     
     
    Step 1: Set up an array variable that will hold our folder names and the associated email recipients
     
     
     
     
    Here's that array to copy/paste into your flow. Be sure to set the email recipients and folder names based on your environment:
    [
      {
        "Recipient": "emailrecipient1@contoso.com",
        "Folder": "Shared Documents/General/TestFolder1/"
      },
      {
        "Recipient": "emailrecipient2@contoso.com",
        "Folder": "Shared Documents/General/TestFolder2/"
      },
      {
        "Recipient": "emailrecipient3@contoso.com",
        "Folder": "Shared Documents/General/TestFolder3/"
      },
      {
        "Recipient": "emailrecipient1@contoso.com",
        "Folder": "Shared Documents/General/TestFolder4/"
      },
      {
        "Recipient": "emailrecipient2@contoso.com",
        "Folder": "Shared Documents/General/TestFolder5/"
      },
      {
        "Recipient": "emailrecipient3@contoso.com",
        "Folder": "Shared Documents/General/TestFolder6/"
      },
      {
        "Recipient": "emailrecipient1@contoso.com;emailrecipient2@contoso.com",
        "Folder": "Shared Documents/General/TestFolder7/"
      },
      {
        "Recipient": "emailrecipient2@contoso.com;emailrecipient3@contoso.com",
        "Folder": "Shared Documents/General/TestFolder8/"
      }
    ]
     
     
     
    Step 2: Set up a string variable and leave it blank
     
     
     
     
    Step 3: Apply To Each using the array variable we set up in step 1
     
     
     
     
    Step 3a: Inside the Apply To Each loop, add a Condition checking the folder that's had a file created or modified against the current folder in our array
     
     
    On the left side you can copy/paste this: @{triggerBody()?['{Path}']}
     
    On the right side, you'll copy/paste this: @{items('Apply_to_each')?['Folder']}
     
     
     
    Step 3a1: Inside the If True box, use an Append to String Variable action to add the recipient's email address to the string variable from step 2
     
     
     
     
    Step 4: Outside of the Apply To Each we'll use a second Condition to make sure we have at least one recipient. This way if a new folder is added to the directory but not the array, the flow will send an email to a default person:
     
     
     
     
    That expression on the left is: @{length(variables('strRecipient'))}
     
     
     
    Step 4a: Inside the If True box, use an Append to String Variable action to add a default recipient email address
     
     
     
     
    Step 5: Now we send the email, setting the Recipients box to use our String variable
     
     
     
     
     
     
    A couple quick notes:
     
    1. The array example given shows how to send the email to multiple users for a single folder
     
    2. If you want to add folders or change recipients, you'll only have to edit the array variable
     
    3. To get the full folder name, you'll want to check a completed flow run's trigger outputs for the {Path} value. From that, you'll be able to easily replicate the structure for all folders in your target directory:
     
  • Suggested answer
    Haque Profile Picture
    3,217 on at

    Here are the 5 steps you can follow - the switch-case approaceh will be easier to manage and debug in this case, i guess.

     
    (1): Trigger: Use the trigger "When a file is created or modified (properties only)" on your document library.
    (2): Get Folder Path: Use the dynamic content from the trigger to get the folder path or folder name of the changed item. This is usually available as Folder path or Path.
    (3): Switch Control: Add a Switch action to evaluate the folder name or folder path.
     
    (4): Cases: Add cases for each folder: 
    • Case "A": Send email to Person #1
    • Case "B": Send email to Person #2
    • Case "C": Send email to Person #3
    • Case "D": Send email to Person #1
    • Case "E": Send email to Person #2
    • Case "F": Send email to Person #3
    • Case "G": (Optional) No action or custom notification

    (5): Send Email: Inside each case, use the "Send an email (V2)" action.

    • Set To to the email address of the person mapped to that folder.
    • Customize the Subject and Body to include details about the updated item.
     
    Please note that:  If you have the full folder path like /Shared Documents/A/SomeSubfolder, you can extract the folder name with this expression:
     
    last(split(triggerOutputs()?['body/{Path}'], '/'))
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • Suggested answer
    Kalathiya Profile Picture
    2,151 Super User 2026 Season 1 on at
    Hello @EC-20041901-0

    You can achieve this in 2 ways.

    #1. Approach 1
    - Create a separate flow for each folder. So, each flow only monitors its own folder. In this scenario no condition is required. Just replicate the same automation for all the folders and change the email in send an email action. 
     
     
    #2. Approach 2 (Recommended)
    - You can use contains() in condition to check whether the folder name exists in the Folder Path. If yes, then send the email accordingly.
    - Similarly you can add conditions for other folders..
     
     
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------

    📩 Need more help? Just mention @Kalathiya and I’ll be happy to assist.

    ✔️ If this answer helped you, please tick “Does this answer your question?” so it can be marked as the Verified Answer.

    💛 A Like always motivates me to keep contributing!

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 791

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 535

Last 30 days Overall leaderboard