Search code examples
powerapps

How to refresh content of PowerApps app field which represent last received email


I've created an app using Microsoft PowerApps which displays the last received email from Office365 mailbox. I've used this function:

Office365Outlook.GetEmails({folderPath:"Inbox/TargetedInboxFolder", fetchOnlyUnread:false, top:1})

But the problem is that my app will not automatically update the field for email body ThisItem.BodyPreview. I get the body of last received email only when I restart my app. How to refresh the content of this field when Office365 receive a new email in folderPath: "Inbox/TargetedInboxFolder" inbox subfolder, without restarting app?


Solution

  • I don't think you can get an auto-refresh, even if you were to create a Flow triggered when a new email is added.

    To manually refresh, add a "refresh" button to your app.

    Set its OnSelect property to:

    ClearCollect(colLastEmail,
      Office365Outlook.GetEmails(
        {
          folderPath:"Inbox/TargetedInboxFolder",
          fetchOnlyUnread:false, top:1
        }
    )
    

    Then set your Gallery Items property to colLastEmail.