web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to extract file ex...
Power Automate
Unanswered

How to extract file extension from email attachment

(0) ShareShare
ReportReport
Posted on by 3

I created the following flow that automatically uploads an attachment to SharePoint. It only triggers when someone sends an email to a shared mailbox with an attachment. It then uploads that file to SharePoint and names it the subject line and the attachment name. I would love to remove the attachment name and just have the file named after the subject of the email. The only problem is, It doesn't preserve the file extension unless I include "Attachment Name". Is there a way around this issue? 

 

For example, I want the flow to rename the file to the subject. But keep the file extension. The only problem is, that the file extension could be a jpg, png, or bmp. 

 

Screenshot 2022-09-20 083220.png

Note: I edited the image and removed the email address domain and SharePoint site link for privacy. 

Categories:
  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @bbroecker37,

     

    You could use an expression with an indexOf and a slice function to extract the extension part. The index will find the position of the dot character. The slice will only retrieve the dot and what is after the dot.

     

    That expression would be (which you can add via the expression editor instead of the attachments name)

    slice(items('Apply_to_each')?['name'], indexOf(items('Apply_to_each')?['name'], '.'))

     

    Together with that Subject part it would be something like below (which you can paste as plain text)

     

    @{triggerOutputs()?['body/subject']}@{slice(items('Apply_to_each')?['name'], indexOf(items('Apply_to_each')?['name'], '.'))} 

     

    slicefunction.png

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 271

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard