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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collection of emails f...
Power Apps
Answered

Collection of emails from SharePoint List

(0) ShareShare
ReportReport
Posted on by 146

Hi

 

I am trying to collect email addresses from SharePoint List. following two formulae work fine if I dont use "email" and "{}" . But when I use it in the following way I doesn't fetch anything. This is triggered when user presses a button on an item of gallery.

I need to include "email" property to use it in Concat function in Bcc part of email as mentioned at the end of the code. 

 

Regards

 

 

If(ThisItem.'Status of Action(A)'.Value = "Pending",
Collect(colEmails,{email: Filter(SP_List,Role = "A")}));
If(ThisItem.'Status of Action (B)'.Value = "Pending",
Collect(colEmails,{email: Filte(SP_List,Role = "B")}));

//I want to use this collection as Bcc email address in an email through PowerApps 
{Bcc: Concat(colEmails,email,";"), Importance: "Normal"}

 

 

The above code works fine in the following way, But I dont know how to use this array in Bcc with Concat function as there is no field email in this case. 

{Bcc: Concat(colEmails,email,";")}

 

If(ThisItem.'Status of Action(A)'.Value = "Pending",
Collect(colEmails,Filter(SP_List,Role = "A"));
If(ThisItem.'Status of Action (B)'.Value = "Pending",
Collect(colEmails,Filte(SP_List,Role = "B"));

 

Categories:
  • Verified answer
    AldenKnibbs Profile Picture
    107 on at

    In PowerApps, when you're collecting items into a collection, especially when intending to use properties of those items later (like for email addresses in a Bcc field), it's important to ensure the structure of your collection aligns with your usage intentions. Based on your description, it seems there's a small misalignment in how the collection is being populated with email addresses and how you're attempting to use it.

    Let's address the issue step by step to ensure you can collect email addresses correctly and then use them in a Concat function for the Bcc part of an email.

     

    Correcting the Collection of Email Addresses
    When you use Collect(colEmails, {email: Filter(SP_List, Role = "A")}), it attempts to create a record with an 'email' column containing the entire result of the Filter function, which is not what you want. Instead, you need each item returned by Filter to be a separate record in your colEmails collection, and you want to extract a specific field from each item (presumably an email field within your SP_List).

    You likely have an 'Email' column (or similar) in your SP_List that you're trying to collect. The corrected approach involves using the ForAll function along with Collect to iterate over each item returned by Filter and collect their email addresses into colEmails.

     

    Example Solution
    Assuming your SharePoint list (SP_List) has an 'Email' field that you want to collect:

    1. Correct Use of Collect and ForAll:
    If(ThisItem.'Status of Action(A)'.Value = "Pending",
     ForAll(Filter(SP_List, Role = "A"), Collect(colEmails, {email: Email}))
    );
    
    If(ThisItem.'Status of Action (B)'.Value = "Pending",
     ForAll(Filter(SP_List, Role = "B"), Collect(colEmails, {email: Email}))
    );

     

    In this corrected version, ForAll iterates over each item returned by the Filter function. For each item, it collects a record into colEmails where the 'email' field is set to the 'Email' value of the current item.

     

    1. Using Concat with the Corrected Collection:
    {Bcc: Concat(colEmails, email, ";"), Importance: "Normal"}

     

    This line correctly concatenates all email addresses in the colEmails collection, separated by semicolons, which is the format typically required for email address fields like Bcc.

     

    Final Notes

    • Ensure the field name ('Email' in this example) matches exactly with the field name in your SharePoint list that contains the email addresses.
    • This solution presumes you want to add email addresses to colEmails based on the status of actions 'A' or 'B'. This will collect emails each time the conditions are met, potentially leading to duplicates if the button is pressed multiple times. Consider clearing colEmails before collecting (using Clear(colEmails)) if duplicates are a concern.
    • Adjust field names as necessary to match your actual SharePoint list schema.

     

  • AppDeveloper Profile Picture
    146 on at

    Hi @AldenKnibbs 

     

    This has not only resolved the issue but also educate me. Thanks a million

     

    Regards

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard