cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VTobiska
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
v-xida-msft
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
v-xida-msft
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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,821)