Last week, I was working on a Power Automate flow and received a requirement to create a file in a SharePoint library whenever a new email with an attachment arrives. The client wanted to automate the process so that when an email containing an attachment is received, the attachment is automatically saved as a file in a specific SharePoint folder.
In this tutorial, I will explain how to use the Create File action in Power Automate. Additionally, I will cover:
- How to create file using Power Automate
- How to create an Excel file in SharePoint using Power Automate
- How to create a file in OneDrive using Power Automate
Create File Action in Power Automate
The Create File action in Power Automate creates a new file in a specified location, like OneDrive or SharePoint. You provide details like the file’s name, the folder where it should be saved, and its content (text, data, or an attachment). When the flow runs, this action generates the file in the selected folder with the specified content.
The Power Automate Create File action for SharePoint accepts four parameters.
- Site Address
- Folder path
- File name
- File content

The Power Automate for Create File action for Onedrive business accepts 3 parameters:
- Folder path
- File name
- File content

Create File Using Power Automate
For this example, I created a SharePoint document library named HR Documents.

Now follow the below steps:
1. Create an automated cloud flow. Give the flow name and select the trigger When a new email arrives (V3).

2. Next, we will add get the attachments action from Outlook with the message ID and attachment ID that will automatically add the Apply to each action.

3. Select Create file action for SharePoint. Then, provide the Site address, Folder path, Filename, and File content from the dynamic content.

Now click on Save, and to run the flow, send an email attachment to the Outlook inbox.

Now, you can see in your document library that a new file has been created from the attachment.

You can create a file from an attachment using Power Automate.
Create an Excel File in SharePoint Using Power Automate
Before I explain how to create an Excel file using Power Automate, you need to create an Excel file in a document library. I have already created one.

Now follow the below steps:
1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

2. Now choose a Get file content action for SharePoint Connector and configure the required parameters:
- Site Address: Select the SharePoint site address from the dropdown where we create the blank Excel file.
- File Identifier: Choose the Excel file we created before.

3. Now, add an action to create Excel files in a SharePoint library. Click the + icon to add the Create file action (under the SharePoint connector) and provide the required parameters:
- Site Address: Select the SharePoint site address from the dropdown menu where you store all your Excel files.
- Folder Path: Select the folder path.
- File Name: Provide the Excel file name with the .xlsx extension.
- File Content: Use the dynamic content File Content from the Get file content action.

Now, click Save and run the flow manually after it runs successfully. You will see an Excel file created in the SharePoint document library.

Create File in OneDrive Using Power Automate
In this example, I will show you how to store an attachment in OneDrive when a new item is added to a SharePoint list; you can create a Power Automate flow that extracts the attachment from the new item and saves it into a specific folder in OneDrive.
For this example, I created a SharePoint list with the following columns and data types:

Now follow the below steps:
1. Create an automated cloud flow. Give the flow name and select the trigger When an item is created. Also, provide the Site Address and List Name.

2. Next, we will add the get attachments action from SharePoint and provide the below parameter:
- Site Address: Select a specific SharePoint site from drop-down.
- List Name: Choose a particular list.
- Id: Select Id from dynamic content under When an item is created.

3. After that, take the Get attachment content action to retrieve the details from the attachment. Then, Provide the below parameters:
- Site Address: Select a specific SharePoint site from drop-down.
- List Name: Choose a particular list.
- Id: Select Id from dynamic content under When an item is created.
- File Identifier: Take Id from the dynamic content of Get attachments.
You can see that a For each loop will be added automatically, taking Body outputs from Get attachments.

4. Next, add the create file action from onedrive and provide the below parameters:
- Folder Path: Select the folder path in OneDrive where the attachments should be saved
- File Name: Use the Display Name from the Get attachments action to maintain the original file name.
- File Content: Use the Attachment Content from the Get attachment content action.

Now click on Save and run the Flow manually. Then, add an item with an attachment to the SharePoint list.

After the flow runs successfully, go to the Ondrive, and you will see that the file has been created.

In this article, I covered how to use the “Create File” action in Power Automate to automate file creation in SharePoint and OneDrive. I explained how to set up a flow that automatically saves email attachments to a SharePoint library.
Additionally, I covered how to create Excel files in SharePoint using Power Automate and store attachments in OneDrive when new items are added to a SharePoint list.
Related Power Automate articles:
- Create an XML file from CSV in Power Automate
- Create a sharing link for a file or folder using Power Automate
- Create PDF File from SharePoint list item Using Power Automate
- Add Days to Date in Power Automate

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.