sharepointpower-automate

Using Power Automate to save emails in SharePoint location based on List Entries


We would like to be saving emails that arrive in Outlook into correspondence folders in SharePoint. I have worked out how to save all emails to a folder, and worked out how to use the 'condition' actions to filter out emails with specific text in the different email fields (to, from, body, etc).

But because we are wanting to be doing this for all our staff's inboxes, and I cannot seem to make flows for the other staff, if anything were to change to the conditions, say we got a new folder to be added for example, I would have to update every single person's flow manually.

So what I would like to be able to do is have the flow behave similar to a VLOOKUP in Excel. When an email comes into the inbox, it compares the 'from' field of the email to a SharePoint list, and if it finds it in that list, it saves the email into a particular folder.

This is my working flow.

It grabs the email and the attachments based on a filter from the From Field no worries, it saves them in a specific folder no worries, saves the attachments no worries. I have a concat there to add the date it was received into the name of the files for both the email and the attachments, and it works perfectly.

I want to be able to add something somewhere, where it finds the folder path from a list in SharePoint. so that I can have a list that's like,

Customer From Field Keyword File Path
Customer 1 @customer.com General>Customers>1
Customer 2 @something.com General>Customers>2

I've made it add items TO a list before, and that's fine, and someone mentioned to me that I should be able to set this up so it will check the list, so I can just make updates to the list instead of to the flow when we get a new customer or the file path needs to change for some reason.

So what I need is some sort of IF or Get Items.

If I put Get Items between the trigger and the condition, it asks about parameters. It lets me save without them but it does complain about it. I then set the condition to look at the 'from' from the email trigger, contains, column in the list with the keyword in it. And then in the Create File actions (for both the email and the attachments) I put the column from Get Items that has the links to the folder I want it saved in. The For Each automatically completed with the body/value item from get items.

But running the flow it doesn't work. The trigger works, and the Get Items works, but at the For Each, Condition, and Create File stages it has a hissy fit and I just don't understand why.

I think I need some sort of expression action to interact with the Get Items action, to pull the file path out of the list, so that the create file actions can look at that instead, but I have no idea what to add.


Solution

  • I FIGURED IT OUT

    Okay so the flow has: Email Arrives Trigger > Get Items > For Each: output body/value (from Get Items)

    Inside the For Each: Condition: From (from Email Arrives Trigger) contains (Column with Keyword from Get Items)

    True Condition: Get Item (Dynamic ID content from Get Items) > Export Email > Create File (folder path field Dynamic File Path from Get Item) > For Each (attachments from Export Emails)

    Inside the second For Each: Create File (same dynamic file path as before), (Attachments content)

    Works amazingly now!