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.
(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
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:
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.
The search result from the Get Items action will contain the folder name:
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:
Here is the entire demo flow, which also checks to see if the lookup (Get items action) returned any results:
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
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!
User | Count |
---|---|
94 | |
44 | |
21 | |
20 | |
16 |
User | Count |
---|---|
137 | |
56 | |
46 | |
36 | |
26 |