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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Rename email attachmen...
Power Automate
Answered

Rename email attachments from the subject/body text as filename in Onedrive

(0) ShareShare
ReportReport
Posted on by 33

Hi All,

 

I am a total Newbie with PA, so I hope someone can be so kind and give me a hand.

 

I have employees fill out a form (Contact Form 7) and attach files to it. The resulting email with attachments lands in my Outlook365 mailbox. 

 

I have the "Save Office 365 email attachments to OneDrive for Business" flow working nicely. What I really need is to have the attachments renamed automatically with text from the email. Specifically what document the attachment is and their employee ID number. 

 

For example, employee 12345 fills out the form and attaches a picture of their ID card. I need the file attachment in Onedrive to be named 12345_ID Card.

 

Thanks so much for reading my problem, and I hope someone can help me out. 

 

Have a great day

 

 

Categories:
I have the same question (0)
  • v-litu-msft Profile Picture
    on at

    Hi @paddy76,

     

    You could use concat() function to combine the Employ name and ID card number:

    concat('<text1>', '<text2>', ...)

     

    Here is an example, after create file in OneDrive folder, rename the file, but should combine the "12345" and "_" with original file name and then add at the end of the folder.

    concat(outputs('Compose_2'),'_',outputs('Create_file')?['body/Name'])

    Screenshot 2020-10-20 145942.jpg

     

    Screenshot 2020-10-20 150001.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • paddy76 Profile Picture
    33 on at

    Hi Lin Tu,

     

    thanks so much for the response. Much appreciated.

     

    Actually, would that solution pull the data from the email? The employee number would change all the time based on who filled the form, so the employee number would not always be 12345. The employee number would be in the subject of the email. PA flow should extract that number and use it to rename the file in Onedrive.

     

    ----

    From: Form@submittedonmywebsite

    To: myemail@outlook.com

    Subject: Employee 54321 just submitted a form

    Attached jpeg

    ----

    In Onedrive the jpeg is renamed 54321.jpeg

     

    Thanks so much for your help 🙂

     

    Paddy

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @paddy76,

     

    You could use the split() function to extract the Employee ID, the split function could convert a string into an array, you could use the special word as a separator to stripping out employee ID, the first split function use "Employee " (here is a blank space), the second split function use " just":

    first(split(last(split(triggerOutputs()?['body/subject'],'Employee ')),' just'))
    

     After get the ID, you could use it to rename the file.Screenshot 2020-10-20 164258.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • NJ-04111117-0 Profile Picture
    6 on at
    I am a newbie and trying to save attachments form mails, Can you please help me how can i save attachment with name as Body of mail.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard