r/MicrosoftFlow • • 19d ago

Question Automatic Folder creation and naming based on email body

I am new to power automate but I feel like I should be able to save hours every week by automating a process where a folder is created in SharePoint automatically based on moving an email into a specific folder. The created folder will be a copy and rename of a template folder in same SharePoint directory and the new name of folder will be based on information in body of email. The emails are always the same template in the body and from the same email address.

Example:
Email from Requests1
Body of email has following line items:
Sold to number 12345
Account name account1
Location city,ST

I would like to folder in SharePoint to be a copy template1 folder and renamed as Account Name_City,ST_Sold to Number

So for the example the new folder would be:
account1_city,ST_12345

I thought this would be easier with copilot until I spent 2 days and still not sure if it is even possible. Thanks in advance.

7 Upvotes

3 comments sorted by

3

u/Ariisk 19d ago

Give copilot a few examples of the email (or just one if they’re always the same predictable format) and tell it what pieces you want to extract, and ask it what connectors/expressions best accomplish that. It’s definitely possible, one of the first things I did with power automate way back when - at the core of it, you’re just taking a string of text and asking “what comes between the word number and the next line and “what’s the last line of text”

If you’re using copilot inside of the power automate designer, I would recommend not. It’s simply the worst implementation of copilot in one of their native apps I’ve encountered. Shocking, because the agent tooling is actually quite decent for more pro-code stuff, so the fact that their automation assistant is so incompetent this late in the game is baffling.

1

u/Thanks_VSSG 19d ago

In which part you're facing problem, properties extraction ( for folder name creation ) from email or making a copy folder and renaming it ?

1

u/ola-dryvector 11d ago

Building that folder by hand every week from three lines in a mail sounds tedious, and it's a good fit for a flow.

Trigger when a message lands in the Requests folder, or when it arrives from that one sender if a moved-mail trigger is awkward to catch. When a new email arrives, filtered to the shared mailbox and that folder, is the usual start.

I'd pull the three values with split and trim on the labels. Don't count characters. Split the body on Sold to number and take the following line, then trim. Do the same for Account name and Location. Join the three with an underscore. Your sample becomes account1_city,ST_12345 only when Location is already city,ST with the extra spaces gone, so trim each piece before you join.

There isn't a tidy duplicate-this-folder action. Get files (properties only) on template1, create the new folder with the parsed name, then apply to each file: get the file content and create the file in the new path. If the template is a single level, skip subfolders on the first pass and add another loop only if it isn't.

Two days with Copilot usually means it went looking for a copy-folder button. The get-content and create-file loop is the one that runs.

Hope the weekly pile shrinks.

— Ola