cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VTobiska
Level: Powered On

Save attachment based on content

Hi,

 

I would like to save files from mails based on their content. If I do not apply any confitions, it is ok. But I added condition

"if content contains ABC" - "save it to folder A" else "save it to B" and this does not work. I tried .txt., .csv, .xls and without success.

 

Do you have any idea?

 

Thank you, Vašek 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Save attachment based on content

Hi @VTobiska,

 

Could you please share a screenshot of your flow's configuration?

Do you want to save files from emails based on the content of the attachment files or the content of the email?

 

If you want to save files from emails based on the content of the attachment files (DOCX file, CSV file, Excel file, etc.), I afraid that there is no way to achieve your needs in Microsoft Flow currently. But if the attchment files is a .txt file, you could take a try with the following workaround:

  • Add a "When a new email arrives" trigger.
  • Add a "Apply to each", input parameter set to Attachments dynamic content of the trigger.
  • Within "Apply to each", add a Condition, click "Edit in advanced mode", type the following formula:
@contains(base64ToString(items('Apply_to_each')?['ContentBytes']), 'ABC')

Within "If/yes" branch of Condition, add a "Create file" action, Folder Path set to Directory A. Within "If/no" branch of Condition, add a "Create file 2", Folder Path set to Directory B.

 

Note: I assume that you save the attachment files into the folder of OneDrive for Business.

 

Image reference:26.JPG

The flow works successfully as below:27.JPG

 

If you want to save files from emails based on the content of the email, please take a try with the following workaround:28.JPG

 

 

Best regards,

Kris

 

 

 

Community Support Team _ Kris Dai
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

1 REPLY 1
Community Support Team
Community Support Team

Re: Save attachment based on content

Hi @VTobiska,

 

Could you please share a screenshot of your flow's configuration?

Do you want to save files from emails based on the content of the attachment files or the content of the email?

 

If you want to save files from emails based on the content of the attachment files (DOCX file, CSV file, Excel file, etc.), I afraid that there is no way to achieve your needs in Microsoft Flow currently. But if the attchment files is a .txt file, you could take a try with the following workaround:

  • Add a "When a new email arrives" trigger.
  • Add a "Apply to each", input parameter set to Attachments dynamic content of the trigger.
  • Within "Apply to each", add a Condition, click "Edit in advanced mode", type the following formula:
@contains(base64ToString(items('Apply_to_each')?['ContentBytes']), 'ABC')

Within "If/yes" branch of Condition, add a "Create file" action, Folder Path set to Directory A. Within "If/no" branch of Condition, add a "Create file 2", Folder Path set to Directory B.

 

Note: I assume that you save the attachment files into the folder of OneDrive for Business.

 

Image reference:26.JPG

The flow works successfully as below:27.JPG

 

If you want to save files from emails based on the content of the email, please take a try with the following workaround:28.JPG

 

 

Best regards,

Kris

 

 

 

Community Support Team _ Kris Dai
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
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (6,047)