cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

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

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

3 REPLIES 3
Community Support
Community Support

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.

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

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.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (7,044)