cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

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
Community Support

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
Community Support

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
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

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
Users online (5,777)