
Outlook attachments are just raw data, and hence, Power Automate cannot handle them in the usual way. The Excel tools require documents to be saved in OneDrive or SharePoint, and hence, they will just not function here. It is this incompatibility that causes the read-only issue every time.
Where the file is stored is more important than the format when the automation is initiated. First, store the file locally, and then move on to setting up the table structure. Once the file is saved, it is time to organize rows and columns in the required format. This ensures that everything is organized and in place, without any issues cropping up later. Step one, and then comes step two, and so on, and the process is completed without any interruptions or stops. This is how the process runs from start to finish, on its own, without any breaks.
Step 1: Fetch the attachment
First, use "Get attachment (V2)" to fetch the file, rather than directly taking its data from the email trigger. This will ensure that the raw, unprocessed byte stream of the document is received.
Step 2: Save the file
Next, open OneDrive for Business or SharePoint and select "Create file." Put the attachment in any folder that you wish, maybe something like /Temp/Attachments/filename.xlsx. Once the binary data is written out properly, a real file will be created.
Step 3: Create the table
First, select "Create table" in the Excel Online (Business) tool. It should be targeted at the file in the Excel Online (Business) tool from step two. This links the tool to the actual file instead of the attachment path.
Why it avoids the read-only problem
Outlook has attachments locked by default, which limits the possibilities of what can be achieved. The Excel tool can't access the table information because it can't edit the file information either. The solution of using the OneDrive/SharePoint folders avoids the problem naturally.
Keep the folder clean
The final part of the code should remove the file after the table has been created or the information has been extracted. If the code is run many times, the folder will become cluttered with files that are no longer necessary. Adding the "Delete file" option in the OneDrive tool should be the final part of the code.
Full automation with no human involvement
The code starts by itself when a new email is sent to the inbox. It selects the new message, grabs the file, stores it in the OneDrive tool, creates a table, retrieves the information, deletes the file, and completes the task without human involvement. The code handles the entire task by itself, from the beginning to the end, without human involvement such as downloads and openings.