web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Flow needs to only process csv attachments, sends message if email contains other files but not csv

(0) ShareShare
ReportReport
Posted on by

I have a flow built that looks at the attachments in an email and if there is a csv file it saves the file and sends a copy to an sFTP.

 

However, sometimes in addition to the csv there will be image files. And sometimes there will only be image files. In the case where there are only image files I want to send an email out to a group to let them know there was no csv attached. 

 

But currently if I evaluate with the Yes No condition and say Yes process the file or No send an error message email the error message email always goes out when there are multiple files of csv and image. I need the email to only go out if the attachments were not csv.

 

I know I can create two flows to handle the entire situation but it seems like I should be able to do this with one, using an array. But when I tried that it errored out because I used the Attachment Name to ensure there was a csv.

 

How can I do this?Capture1.PNGCapture2.PNGCapture3.PNG

I have the same question (0)
  • tom_riha Profile Picture
    10,179 Most Valuable Professional on at
    Re: Flow needs to only process csv attachments, sends message if email contains other files but not csv

    Hello @Anonymous ,

    your condition will probably never be Yes, the 'contains' operator is designed for an array, if an array contains given value. In your case it seems you want to compare string (I guess the left side in your conditions is 'Attachments Name'), for which the operator 'ends with' will be better.

    image.png

    Also, the 'Apply to each' action will process all attachments in the email one by one. In case your email has 2x .png file and 1x .csv file, it'll check the 1st .png file and send an email (it's not .csv). It'll check the 2nd .png file and send an email (it's not .csv). It'll check the .csv file and upload all the files.

    To check if one of the attachments is .csv and process the whole email accordingly I'd add a boolean variable and one 'Apply to each' action dedicated only to searching for the .csv file. If the variable is set to true at the end of this 'Apply to each', then there's a .csv file in the attachment. If it's still false, send the email.

    image.png

     

  • Verified answer
    Paulie78 Profile Picture
    8,418 Moderator on at
    Re: Flow needs to only process csv attachments, sends message if email contains other files but not csv

    I would change approach slightly. Simply filter the array of attachments, before you loop through them to contain only CSV files.

     

    Here I sent myself a .csv and a .txt, but only the .csv remains in the filter array. You can then do a condition based on the length of the filter array and use that as a basis for the email to send or not. This would also be a bit faster.

     

    FilterAttachments.PNG

     

    Make sense? Using this method you never have to be concerned with the other non .csv attachments.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 659 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 386 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard