@AGR2 You need to use the split() function. I cover how to do use the function in this section of my YT Tutorial: 7 Functions You Need to Know | ⚡️Expression Essentials: Part 1⚡️
In the full tutorial I cover 7 functions you need to know when getting started with expressions.
1️⃣ empty()
2️⃣ coalesce()
3️⃣ equals()
4️⃣ if()
5️⃣ concat()
6️⃣ length()
7️⃣ split()
I cover how to use these functions in expressions and I’ll also cover common mistakes when it comes to writing expressions and show you a few tips and tricks along the way.
As a beginner or even an intermediate flow builder—expressions can seem a bit complex at first, I’m going to try to simplify it for you. If you want to level up your flows by writing expressions—keep watching!
IN THIS VIDEO:
✅ What is an Expression?
✅ What is a Function?
✅ What Does Wrapping a Function Mean?
✅ How Do I Insert an Expression?
✅ How to Use a Compose action
✅ How to Navigate the Expression Builder with Arrow Keys
✅ How to use the Expression Tooltip
✅ Common Mistakes When Writing Expressions
✅ How to differentiate a null from an empty string
✅ How to Get Dynamic Content When it’s Not Listed
✅ How to Use a Get Item Action to Verify Dynamic Content Output
✅ How to Convert Strings to Lower Case
✅ How to Troubleshoot the if() Function
----
Manual Trigger
I always create a manually triggered flow when building and testing my flows. I also like to keep a copy of a manually triggered flow for testing and troubleshooting purposes at a later date.
Use the Email ID of an email for testing purposes. Insert the ID into a Get Email (V2) action.
Loop through Attachments
If you only ever expect a single attachment, you can avoid the Apply to Each action by using an expression. I cover how to do that in this YT Tutorial: 3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow
Add an Apply to Each action to loop through the Attachments.
Add a Compose action to hold the Attachments Name dynamic content. This action is optional, however it helps to better understand the flow and makes it easier to reference the dynamic content in the expression. Tip: Rename your actions to keep your flow organized. This is especially important if you have multiple instances of the same action.
Add another Compose action to store the expression. You'll need to use the split() function. The split() function takes two parameters:
split([string to split],[separator])
Click on the dynamic content tab and insert the output from the Compose action above (the one storing the current attachment name of the attachment that is being looped through).

Add a comma and single quotes. Between the single quotes insert a single space.

Run a test. Review the outputs. The split() function will take the attachment name (string) and convert it into an array splitting the string at any spaces in the attachment name.
In my example I have a number in my file name and it appears on the third line. Array item index starts at [0]. This means the first item is [0], second is [1], third is [2] etc.
In my case, the item index for my item is [2].

The first() and last() function can also be used to get the first or last item in an array (respectively).
Get the File Extension
First, we'll need to return the file extension. Add another Compose action and insert an expression. Use the last() function. We'll use this to return the last item in the array so we can get the file extension.

Insert the output from the Compose action above.

Run a test. This expression should output the last line of the array.

To get the file extension, you'll need to split this at the period and return the last item of that array. Click on the expression label to edit it. At the start of the expression enter split with an opening parenthesis.

Press the down arrow key to go to the end of the expression. Add a comma and a period between single quotes.

Don't forget to press update and run another test. The expression should now output an array.

You need to return the last item in the array. Click on the expression to edit it and wrap the entire expression in the last function. At the start of the expression enter last with an opening parenthesis.

Go to the end of the expression by pressing the down arrow key and enter a closing parenthesis.

Run a test. Review the output.

Now that you have the extension you'll need to add in the file name. You can combine everything into a single expression if you'd like. To make it easier on you, I'll recommend you insert a separate expression. Place your cursor right before the existing expression in the Compose action.

The expression field should be empty. Enter another expression. As mentioned before, my number is the third item in my array. You will need to adjust this based on your array. The third item has an item index of [2]. Remember the item index starts at [0].

Insert a question mark and your item array.

Place your cursor at the start of the expression by pressing the up arrow key. Insert the output from the Compose action above (that contains the attachment name array).

Press Ok. This should insert another expression label into the Compose action. Don't forget to add a period between the two expression labels.

Run a test. Review the outputs.

To get the attachment content, refer to this YT Tutorial: Save Email Attachments to SharePoint with Microsoft Power Automate
Power Automate doesn’t have a download attachment from outlook action. In this Power Automate Video tutorial, I’ll show you how to use the Get Attachment (V2) action in combination with the Create File action to get your email attachments onto SharePoint.
The Create File action will overwrite any files that already exist with the same name. In this tutorial, I’ll show you how you can append a timestamp to the end of a file name to prevent your file from being overwritten.
I’ll also show you how to set up your flow so that you can trigger it manually while building it so you don’t need to wait for an email to arrive. At the end of the video I’ll show you how adding trigger conditions to your flow can prevent it from triggering if certain conditions aren’t met. Although the final flow uses the When a new email arrives in a shared mailbox (V2) trigger, you can use any of the When a new email arrives triggers for your flow. Adjust this flow to suit your needs!
IN THIS VIDEO:
✅ How to Automate Downloading and Uploading Email Attachments to SharePoint
✅ How to Use a the Get Email (V2) action
✅ How to Use the Get Attachment (V2) action
✅ How to Create Attachment Files using the Create File Action
✅ How to Prevent the Create File Action from Overwriting a File
✅ How to use Split the Filename from its Extension
✅ How to Append a Timestamp to a File Name
✅ How to use the When a New Email Arrives in a Shared Mailbox (V2) trigger
✅ How to use the Convert Time Zone action
✅ How to add Trigger Conditions to your Flow
Hope this helps!
If I helped you solve your problem—please mark my post as a solution
✅.
Consider giving me a
👍 if you liked my response!
👉 Level up your Power Automate skills by checking out my tutorials on
YouTube👉 Tips and Tricks on
TikTok and
Instagram