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 / Advanced Email Routing...
Power Automate
Unanswered

Advanced Email Routing of Mailflow Based on Email Body in Shared Mailbox

(0) ShareShare
ReportReport
Posted on by 3

I am having trouble with routing rules and attempting to solve this issue using Power Automate to move emails coming into the inbox of a shared mailbox. We currently use Inbox rules on the shared folder but we keep running into issues of codes being used further down in the email chain and triggering the move rule. There is no way to correctly order these and I do not know of a way to search just a section of the body of the email for a specific trigger so I am attempting to use Power Automate for this.

 

I currently have a list of 40 possible routes an email could go based on trigger codes in the first body of the email. I have the flow working for a single condition for searching for one code. But the conditions fail if I branch to multiple conditions or put a second condition under the "no" of the first condition. I am splitting the email body on the company phone number in the signature line to get the first message body without any reply data to omit previous routing codes and trying to route the new email soley based on the body of the most recent email.

 

What is the best approach for handling this?

 

Flow currently:
Trigger: When email arrives in inbox

Convert email body to HTML

compose - uriComponent(body('Html_to_text'))

compose 2 - split(outputs('Compose_2'),'800-555-6571')

compose 3 - decodeUriComponent(first(outputs('Compose_-_Split_After_Phone_Number')))

initialize - type: string, value: output of compose 3

 

condition - searching the initialized string for codes and move to correct folder

 

What i am wanting to do is

- If first split output contains "ooo", move to "Orders" folder

- If first split output contains "qqq", move to "Quotes" folder

- If first split output contains "rga", move to "Returns" folder

 

The below works for a single condition only.

Mail Route Flow.PNG

Categories:
  • Ellis Karim Profile Picture
    12,379 Super User 2026 Season 2 on at

    (1) Can you post some examples what the data looks like, and what you are trying to extract from the body text

    (2) Routing rules - are you moving emails into folders within same Shared Mailbox? So 'ooo' will be moved in to a folder called Orders  within the same mailbox?

    Ellis

  • Ellis Karim Profile Picture
    12,379 Super User 2026 Season 2 on at

    We can leverage a SharePoint list and avoid having to 40+ conditions in Power Automate. We can create a lookup table. Given the operating trigger code (e.g.. 'ooo',  'qqq' or 'rga') we want SharePoint to return the routing folder name. I am assuming that the email needs to be moved to a folder within the same shared mailbox.

    In the SharePoint list called Routing there are only two columns: Title which stores the operating codes, and Folder which corresponds to a folder name in the shared mailbox:

    ekarim2020_0-1629568413750.png

    Using a list in this way will allow us to add, change or delete operating codes and folder names without need to update the flow.

    We use the Get Items action and search for the operating code using an ODATA filter query. In the example below I use the email's subject line as the operating code - just to keep things simple.

    ekarim2020_2-1629569099515.png

    The search result from the Get Items action will contain the folder name:

    ekarim2020_7-1629570288037.png

     I then use an expression to extract the folder name and store that in a compose action. Finally I move the email to the extracted folder name using the Move email (v2) action:

    ekarim2020_8-1629570737028.png

    Here is the entire demo flow, which also checks to see if the lookup (Get items action) returned any results:

    ekarim2020_6-1629569584455.png

    The question now becomes how easily or reliably can you extract the operating codes from the body of the email?

    I hope this helps.

    Ellis

     

  • Larson-JB Profile Picture
    3 on at

    This looks like a comprehensive solution to my issue. I am going to test it out this week and see how it works. But I think this may be the solution I need. Thank you very much!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 288 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard