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.
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.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 476 members 4,497 guests
Please welcome our newest community members: