Skip to main content

Notifications

Power Automate - Building Flows
Answered

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

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

 

 

  • NJ-04111117-0 Profile Picture
    NJ-04111117-0 6 on at
    Rename email attachments from the subject/body text as filename in Onedrive
    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.
  • Verified answer
    v-litu-msft Profile Picture
    v-litu-msft on at
    Re: Rename email attachments from the subject/body text as filename in Onedrive

    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.

  • paddy76 Profile Picture
    paddy76 33 on at
    Re: Rename email attachments from the subject/body text as filename in Onedrive

    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

  • v-litu-msft Profile Picture
    v-litu-msft on at
    Re: Rename email attachments from the subject/body text as filename in Onedrive

    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.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard