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 Automate / Send emails with attac...
Power Automate
Suggested Answer

Send emails with attachments from Powerapps

(2) ShareShare
ReportReport
Posted on by 24
Hello!
 
I am trying to send an email from a button trigger on powerapps but include attachments. 

On PowerApps I am selecting multiple items from a gallery using a check box. OnCheck, I am collecting all checks and creating a collection called colPickUp which could have many rows with different items. 

Inside a list, those items have attachments.
 
On PowerAutomate i was able to create the email and send it with the subject and body I want, but I am trying to figure out how to have a way to get attachments and then include them all in the email.
 
What I did was below:
I connected the sharepoint and the list name, but I was wondering how to get all of the IDs in the collection (or if that's even possible).
Example, if my collection has ID 1 on row 1 and ID 2 on row 2, I wanted to get the attachments on both ID's. 
 
 
And then How can I send it through email? On powerautomate i have:
 
but not sure how to include the attachments.
 
Thanks!
Categories:
I have the same question (0)
  • Suggested answer
    Sunil Kumar Pashikanti Profile Picture
    2,058 Moderator on at
     
    If you're trying to send attachments from multiple SharePoint items in a single email, you’ve probably noticed that the Get attachments action only accepts one ID at a time. It doesn’t support passing a collection directly, but there’s a standard workaround.

    Collect all attachments into an array as the flow runs, then pass that array into the email action at the end.
     
    Steps
    1. Initialize an array
    At the start of the flow, add an Initialize variable action:
    Name: varFiles
    Type: Array
    Leave it empty
     
    2. Loop through selected items
    Use an Apply to each loop over the IDs coming from Power Apps.
     
    3. Get attachments (metadata)
    Inside the loop, use Get attachments with the current item ID.
    4. Get attachment content
    Add a nested loop (since each item can have multiple files), and use Get attachment content to retrieve the file data.
     
    5. Build the array
    Use Append to array variable with this structure:
    {
      Name: DisplayName,
      ContentBytes: Attachment Content
    }
     
    6. Send the email
    After the loops (outside of loop):
    Add Send email (V2)
    In the attachments field, switch to “input entire array”
    Use varFiles
     
    Summary
    Since SharePoint attachments are item-based, you need to fetch them per item and aggregate them yourself. Once they’re in an array, sending them in one email becomes straightforward.
     
    ✅ If this answer helped resolve your issue, please mark it as Accepted so it can help others with the same problem.
    👍 Feel free to Like the post if you found it useful.

    Sunil Kumar Pashikanti, Moderator
    Blog:
     https://sunilpashikanti.com/posts/
  • Suggested answer
    Valantis Profile Picture
    4,827 on at
     
    Good question. The key is passing all the IDs from Power Apps to the flow, then looping through them in Power Automate to collect all attachments before sending the email.
    In Power Apps, when you trigger the flow from the button, pass the IDs as a JSON string:
    YourFlow.Run(JSON(ShowColumns(colPickUp, "ID")))
    This converts your collection to a JSON array like [1, 2, 3] and sends it to the flow as a text parameter.
    In Power Automate:
    1. Accept the IDs as a text input parameter
    2. Add a Parse JSON action to convert the text back to an array. Use schema: { "type": "array", "items": { "type": "object", "properties": { "ID": { "type": "integer" } } } }
    3. Initialize a variable (array type) called varAttachments
    4. Add an Apply to each loop over the parsed JSON array
    5. Inside the loop: Get attachments (SharePoint) using the current item's ID
    6. Add another Apply to each loop inside for each attachment returned
    7. Inside the inner loop: Get attachment content (SharePoint) using the attachment's ID and file name
    8. Append to array variable: { "Name": attachment file name, "ContentBytes": attachment content }
    9. After both loops: Send an email (V2) and in the Attachments field, use the varAttachments array
    The Send email V2 action accepts attachments as an array with Name and ContentBytes properties, so this maps directly.
    One thing to confirm: in your Get attachments action, connect it using the same SharePoint site and list, and set the Item ID to the ID from your loop's current item. If your column name in the collection is different from "ID", adjust the JSON column name accordingly.
     
     
  • Suggested answer
    11manish Profile Picture
    1,973 on at
    Yes, you can send attachments from multiple selected SharePoint items, but you must pass only the selected item IDs from Power Apps to Power
     
    Automate, then loop through those IDs in the flow to retrieve attachments from SharePoint, collect them into an array, and finally attach them to
     
    the email before sending.
     
    Power Apps collections cannot directly pass nested attachments, so the logic must be handled in Power Automate.
  • Suggested answer
    Haque Profile Picture
    2,421 on at
     
    Based on the requirement - the core challange is pick up respective attachments from the SP list wheareas all items details are coming from PowerApps.
     
    The collection you have created at the PowerAps side need to be passed to the PowerAutomate - and the do the neccessary housekeeping (pickup the attachment, build the email content and then send the email)
     
     
    Here are the clean steps you can follow:
     
    • PowerApps: Pass Selected Item IDs to Power Automate: Collect selected items in a collection (e.g., colPickUp, that you have did already). Pass only the IDs to Power Automate as a JSON array:
     
            YourFlow.Run(JSON(ForAll(colPickUp, ID), JSONFormat.None))
    
    
    • Power Automate: Receive and Parse IDs: Trigger: PowerApps or manual trigger with an input parameter for the array of IDs. Use Parse JSON action to parse the incoming array of item IDs.
    • Initialize an Array Variable for Attachments: Create an array variable (e.g., AttachmentsArray) to store all attachments for the email.
    • Loop Through Each Item ID: Use Apply to each on the parsed IDs array.
    • Get Attachments for Each Item: Inside the loop, use Get attachments SharePoint action with (Site Address, List Name, Current item) ID from the loop
    • Loop Through Each Attachment: Add a nested Apply to each on the attachments output.
    • Get Attachment Content: For each attachment, use Get attachment content action ( Configure: Site Address, List Name, Current item ID, Attachment file name)
    •  Append Attachment to Array Variable: Append to AttachmentsArray an object with: json
              {
                  "Name": "<attachment file name>",
                  "ContentBytes": "<base64 content from Get attachment content>"
              }
    
     
    • Send Email with Attachments: Use Send an email action (Outlook connector). Fill in To, Subject, and Body fields as needed. In the Attachments field, pass the AttachmentsArray variable.

     

     

    Important notes:

     

    • The base64 content from Get attachment content is ready to use directly - you don't need to do anything.
    • We need to make sure your PowerApps collection passes only the IDs to keep the payload light.
    • If attachments are large or numerous, be mindful of email size limits.
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!

     

  • VO-16022037-0 Profile Picture
    24 on at
     
    I've gotten what you all sent here and that helped a lot! thank you!
     
    However, I'm still having some troubles with the flow failing on different steps depending on what I try to fix..
    Currently I have:
     
    'PowerAppV2->Sendanemail(V2)'.Run(EmailListFlow.TextSubjectEmailReqPick.TextBodyEmailReqPick.TextJSON(colPickUpID) )
     
    1. On a button's OnSelect on PowerApps, I have:
     
    2. When PowerApps Calls a flow
    With 4 different text parameters:
    - EmailList (with the emails I want to send)
    - SubjectEmail
    - BodyEmail
    -colPickUpID (this is a collection with the ID's only, but the output ends up being something like:  
     
    3. Initialize Variable
    4. Compose (which is what I'm having most trouble on)
    This was an effort to converting the string of colPickUpID into an array
     
    5. Big Loop - Apply to Each ID
     
    The Outputs on "Apply to Each ID" is the outputs of compose from the step before
     
    6. Get Attachments
    Here I'm linking my sharepoint address and list. On the ID, I have the "apply to each ID"'s current item
    7. Apply to each Attachment (inside the big loop)
    The output selected in the Body of "get attachments"
    8. Get attachemnt content, I have ID as current item from "apply to each ID" and File identifier as "get attachments, ID"
    9. Append to array variable:
    Name: Apply to each attachment, display name
    Content Bytes: body(get attachments)
     
    10. Lastly, the email 
     
    Where do you think could be the problem?
    Thanks!
     
  • Sunil Kumar Pashikanti Profile Picture
    2,058 Moderator on at

    WHY YOUR FLOW WAS FAILING

    Issue Impact
    JSON not parsed properly Loop fails
    Extra loop Wrong context → intermittent failures
    Wrong File Identifier Attachment content fails
    Wrong ContentBytes Email fails or blank attachments
     
    1) Passing JSON(colPickUpID) from Power Apps, then putting it directly in Compose. This is still treated as string, not an array.
    In Compose, use:
          json(triggerBody()['colPickUpID'])
     
    2) Nested loop is unnecessary (and causing issues). From your screenshot:
    Apply to each ID
       → Get attachments
       → Apply to each Attachment
           → For each   ❌ (extra loop)
               → Get attachment content
    You have double looping on attachments, this is wrong. Remove that extra "For each", that’s breaking your context.
    Fix structure (correct flow)
    Apply to each ID
       → Get attachments
       → Apply to each Attachment
           → Get attachment content
           → Append to array variable
     
    3. "Get attachment content" mapping is WRONG
    Correct mapping
    Inside Apply to each Attachment:
    ID → current item (from outer loop ✅)
    File Identifier → Identifier (from Get attachments output)
    NOT ID
     
    4. Append to array variable, small mistake
    You are using:
    {
      "Name": DisplayName,
      "ContentBytes": Body
    }
    Problem:
    Body is from Get attachments, not actual file content
    Fix
    Use from Get attachment content:
    {
      "Name": items('Apply_to_each_Attachment')?['DisplayName'],
      "ContentBytes": body('Get_attachment_content')?['$content']
    }
    This is mandatory for email attachment
     
    If you fix the JSON parsing + loop structure, your flow should stabilize
    Let me know if you still see failures, happy to take a closer look!
  • Suggested answer
    Haque Profile Picture
    2,421 on at
     
    If you follow my given steps - you will see I have mentioned two Loops - that Sunil has spotted from the screenshot. I believe the steps Sunil mentioned will solve the issues you were facing.
     
    I want add a simple one - when declare an array make explicitly empty:
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
     
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,139 Super User 2026 Season 1 on at
    Hi,
     
    1. Send all selected IDs from Power Apps to the flow
    Convert your collection exam: colPickUp into a list JSON or comma-separated IDs like 1,2,3 and pass it to power automate.
     
    2. Loop through each ID in the flow
    Add an Apply to each step using the IDs you passed.
    Inside the loop, put your get attachments action and use the current ID.
     
    3. Get and store all attachments
    Inside the loop:
    Use get attachments---then get attachment content
    Add each file to an array variable (name + ContentBytes)
    example: 
    Use from get attachment content:
    {
      "Name": items('Apply_to_each_Attachment')?['DisplayName'],
      "ContentBytes": body('Get_attachment_content')?['$content']
    }
     
    4. send one email with all attachments

    After the loop finishes, use Send an email V2 action and pass the array in the attachments field.
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 820

#3
Haque Profile Picture

Haque 505

Last 30 days Overall leaderboard