1
votes

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?

2

2 Answers

1
votes

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.

1
votes

As SeaDude said, this won't refresh automatically, but you can use a timer on the app. Set the following properties

  1. AutoStart: true
  2. Repeat: true
  3. Duration: set to the time interval between refreshes in milliseconds. So 10 seconds would be 10000. I would set at least 1 minute (60000) but longer is probably better.
  4. Visible: false

Set the OnTimerEnd proprety to collect your email times

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

And then set your Gallery to use the ColLastLEmail collection.