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

Save Attachement from email and rename file without date

Hi, I am new with Power automate.

 

I am trying to save attachement from email into a my own folder. This parts works well if I only use the name of the file. My issue is to save this file with the another name.

 

The files comes with a project name follow by the date of the day. Example: 56Afnvproject_20220815.xslx. I would like to delete the date at the end of the file so other system can find the file.

 

My daily email only contains one file. 

 

Thanks,

 

Pierre

1 ACCEPTED SOLUTION

Accepted Solutions
MarconettiMarco
Super User
Super User

Hello @Pierre_EOLEN ,

in the number of last characters to be removed is always the same, you can follow this steps:

1. Add the "Get attachment (V2)" action:

The Message Id and Attachments Attachment Id are grabbed from the Trigger

MarconettiMarco_0-1660888940808.png

2. Add a "Compose" action in which put the following expression:

substring(items('Apply_to_each')?['name'],0,sub(length(items('Apply_to_each')?['name']),14))

This function will remove the last 14 characters, including the extension ".xlsx"

MarconettiMarco_1-1660889064921.png

3. Add the OneDrive "Create file" action, where put the previous Compose outputs in the "File Name" +.xlsx

MarconettiMarco_2-1660889151883.png

Add the "Content Bytes" value, grabbed from the "Get Attachment" action, in the "File Content" field.

 

If I have answered your question, please mark my post as Solved.
If you like my response, please give it a Thumbs Up.

BR,

Marco

 

 

View solution in original post

2 REPLIES 2
MarconettiMarco
Super User
Super User

Hello @Pierre_EOLEN ,

in the number of last characters to be removed is always the same, you can follow this steps:

1. Add the "Get attachment (V2)" action:

The Message Id and Attachments Attachment Id are grabbed from the Trigger

MarconettiMarco_0-1660888940808.png

2. Add a "Compose" action in which put the following expression:

substring(items('Apply_to_each')?['name'],0,sub(length(items('Apply_to_each')?['name']),14))

This function will remove the last 14 characters, including the extension ".xlsx"

MarconettiMarco_1-1660889064921.png

3. Add the OneDrive "Create file" action, where put the previous Compose outputs in the "File Name" +.xlsx

MarconettiMarco_2-1660889151883.png

Add the "Content Bytes" value, grabbed from the "Get Attachment" action, in the "File Content" field.

 

If I have answered your question, please mark my post as Solved.
If you like my response, please give it a Thumbs Up.

BR,

Marco

 

 

Thanks a lot Marco,

 

If people are beginner like me, the compose and create must be inside the loop. I had to do some test before succeed it.

 

Pierre

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,809)