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 Apps / Power Apps - Saving Se...
Power Apps
Unanswered

Power Apps - Saving Selected Outlook Emails as Files in SharePoint

(1) ShareShare
ReportReport
Posted on by 3

Hi Experts,

I'm developing a Power App with three screens: Home, New Request, and Browse Mail. Users start on the Home screen and click the "+" icon to navigate to the New Request screen. This screen contains a vertical gallery connected to a SharePoint list where users input required information. There's also an "Add Document" icon that takes users to the Browse Mail screen.

The Browse Mail screen displays the user's inbox via a vertical gallery connected to Outlook. I've implemented a checkbox control for email selection:


  • OnCheck: Collect(SelectedEmails, ThisItem)

  • OnUncheck: Remove(SelectedEmails, ThisItem)

  • OnSelect: Set(selectedEmailSubject, ThisItem.Subject)


  •  

A "Save" icon on the Browse Mail screen navigates users back to the New Request screen, passing the selected emails:


  • OnSelect: Navigate(New_Request,ScreenTransition.Fade,{SelectedEmails: SelectedEmails})


  •  

Currently, the SelectedEmails collection is passed to the New Request screen. I need to save the emails selected by the user (contained in the SelectedEmails collection) as files within a SharePoint document library called "Scheme_Approval_Flow". Could you please advise on how to achieve this?

Specifically, I need help with the code to add to the "Save" icon's OnSelect property on the New Request screen. I'm unsure how to iterate through the SelectedEmails collection and save each email as a separate file in the SharePoint library. Any guidance on this would be greatly appreciated.

Thanks in advance!

Categories:
I have the same question (0)
  • Suggested answer
    Jon Unzueta Profile Picture
    1,827 Super User 2025 Season 2 on at

    To save the selected emails as files in the SharePoint document library "Scheme_Approval_Flow," you can use Power Automate to handle the process. Here's a step-by-step guide to achieve this:

    1. Create a Power Automate Flow:

      • Trigger: Use the PowerApps trigger to start the flow when the "Save" icon is clicked.
      • Initialize Variables: Initialize a variable to store the SelectedEmails collection passed from Power Apps.

     Initialize variable:

     Name: SelectedEmails

     Type: Array

     Value: PowerApps trigger output

    2. Loop Through SelectedEmails:

    • Use an Apply to each action to iterate through the SelectedEmails collection.

     Apply to each:

     Input: SelectedEmails

    3.Export Email:

    • Inside the loop, use the Office 365 Outlook - Export Email (V2) action to export each email.

     Export Email (V2):

     Message Id: @{items('Apply_to_each')?['Id']}

     ```

    4.Create File in SharePoint:

    • Use the SharePoint - Create File action to save the exported email in the SharePoint document library.

     Create File:

     Site Address: Your SharePoint site address

     Folder Path: /Scheme_Approval_Flow

     File Name: @{items('Apply_to_each')?['Subject']}.eml

     File Content: @{body('Export_Email_(V2)')}

    5.Return to Power Apps:

    • After the loop completes, return a success message or any other relevant information to Power Apps.

     Respond to PowerApps:

     Status: Success

    6. Power Apps Integration:

    • Modify the OnSelect property of the "Save" icon on the New Request screen to call the Power Automate flow and pass the SelectedEmails collection.

     OnSelect: 

     'YourFlowName'.Run(SelectedEmails)

     ```

    If the response is helpful to you, a like or mark as the correct solution. thank you so much!

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard