cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Get file extension name of outlook email attachment

I'm building a flow where I read email attachments of an email from outlook, renaming each one, and saving the renamed attachments into a sharepoint library. 

 

But how do I get the file name extension of my attachments? I was hoping it was available somewhere inside the Apply to each Attachment on the email action, however I only find the (Attachment)Name property. 

 

I tried some different things, but couldn't solve it. Anyone know how to achieve this? For now, I have hard coded the extension but I'd like to just rename the attachment and keep the extension as is.

 

EmailAttachmentGetExtension.png

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Get file extension name of outlook email attachment

 

Hi @ JoelH,

 

How would you rename the attachments?

 

I have made a test on my side, please refer to workaround below.

  1. Add a trigger “When a new email arrives”. the “Has Attachment” field and “Include Attachments” field both set to “Yes”.
  2. Add an Apply to each, choose the “Attachments” dynamic content of the trigger in the input field.
  3. Inside the Apply to each, add a Compose, choose the “Name” dynamic content of the trigger in the input field to get the attachment name.
  4. Add a Compose2, add an expression below to get the attachment extension name: 
substring(outputs('Compose'),indexOf(outputs('Compose'),'.'),sub(length(outputs('Compose')),indexOf(outputs('Compose'),'.')))

 

     5. Add a Compose3, add an expression below to get the attachment name without the extension name:

      

first(split(outputs('Compose'),'.'))

 

    6. Add an action “Create file” of Sharepoint connector, fill in the Site Address and Folder Path field. You could name the file as me,to combine the “Output” dynamic content of the Compose3 and “(copy)” as the file name, and choose the “Output” dynamic content of the Compose2 as the extension name of the file, Then choose the “Content” dynamic content of the trigger in the File Content field.

 

 1.png2.png

   

When receive an email with attachment, the flow run successfully as below:

 

3.png

 

The screenshot of file in my sharepoint as below:

4.png

 

 

 

 

Regards,
Alice Zhang

Highlighted
New Member

Re: Get file extension name of outlook email attachment

Perfect!! Thank you.

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (5,945)