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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Multiple csv files ema...
Power Automate
Unanswered

Multiple csv files email empty values

(0) ShareShare
ReportReport
Posted on by 107

Hi

 

I've created a flow which is taking data from sharepoint, filtering it, make a csv file for each filtered value (7 branches) and then send out all the csv files in one email. Final step is to delete the data which was send out from sharepoint.

 

Now if in one branch there is no filtered data, the flow run fails and i get the error from the send mail action (Parameter 'Attachment Content' cannot be null or empty), even if there is data from the other branches.

 

Is there a way to send out empty csv that the flow runs anyway through? Or to avoid this error message?

 

The only workaround i'm thinkg of, is to send out each filtered data in a seaparte branch and check with a condition if csv is empty, but i would prefer to do this with one mail.

 

Many thanks

Categories:
I have the same question (0)
  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    Hopefully this is what you're looking for.

     

    For this example, I'm using the following SharePoint List. I'll filter on Pet Species for my CSV tables.

    grantjenkins_0-1675947202623.png

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_1-1675947231907.png

     

    Condition for Dogs

    grantjenkins_2-1675947258286.png

     

    Condition for Cats

    grantjenkins_3-1675947292612.png

     

    Initialize variable creates a variable of type array called csvData. This will contain all the CSV tables that we can add to the email.

    grantjenkins_4-1675947364510.png

     

    Each of the Parallel branches are exactly the same, except for the filtering on Get items, and the name we provide for the CSV table. So, I'll just go through the Dogs branch.

     

    Get items Dogs returns all the items from our list where the Pet Species is equal to 'Dog'.

    grantjenkins_5-1675947442695.png

     

    Condition Dogs checks to see if the length of the items returned is greater than 0 (at least one item returned). If the condition is true, we go into the Yes branch and create our CSV table. The expression used is:

    length(outputs('Get_items_Dogs')?['body/value'])

    grantjenkins_11-1675948331899.png

     

    Within the Yes branch...

     

    Create CSV table Dogs uses the output from Get items Dogs and maps a couple of fields that we want in our CSV table.

    grantjenkins_6-1675947594084.png

     

    Append to array variable Dogs appends our CSV table to our csvData array variable.

    {
    "Name": "Dogs.csv",
    "ContentBytes": @{body('Create_CSV_table_Dogs')}
    }

    grantjenkins_7-1675947661557.png

     

    After all the parallel branches have completed our csvData array would contain all the CSV tables that were created.

     

    Send an email uses the csvData array variable as the Attachments array. Note that for our Attachments, we need to switch to input entire array, then add our csvData variable.

    grantjenkins_8-1675947905732.png

     

    When we run the flow, an email will be sent with all the CSV files we created (the branches that had at least one item).

    grantjenkins_10-1675948150838.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

     

     

  • marczh Profile Picture
    107 on at

    awesome this is working out just as needed.

     

    Many thanks.

     

    Given the name of your pets, i suppose your from power apps 911 😉

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard