Power Automate – Flag and Unflag the Email on Shared Mailbox

This blog will discuss how to flag and unflag (Complete) emails on Shared Mailbox.

Background

We have a use case for processing invoices once they are received through email. To process an invoice, we read it using OCR/AI and Send it to Dynamics 365 F&O (Finance and Operations) once it has been processed successfully.

This blog will review how to flag shared emails through Power Automate. To do this, we have to use the “Office 365 Users” connector and the action “Send an HTTP request.”

The Power Platform connector “Flag Email” works exclusively for regular email accounts and is not compatible with shared email accounts.

Solution

  • Create Power automate flow with the trigger called “When a new email arrives in a shared mailbox (Vx)”

  • Add a connection to “Office 365 Users”
  • Find the action called “Send an HTTP request”

  • Set the below inputs
  • URI
    • https://graph.microsoft.com/v1.0/users/<Shared Email Address>/messages/Message Id

Method: PATCH

Body:

{
“flag”: {
“flagStatus”:”flagged”
}
}

Content-Type: application/json

Flag Email

Here is how it shows or is displayed on Outlook

Full Flow for Reference

  • The flow is just a sample to show the Flag.
  • Invoice Document processing is where we extract the content using OCR/AI and process it

Unflag Email

  • The only difference between the flag and unflag is the JSON load
  • Set the Body to unflag/complete it
  • {
    “flag”: {
    “flagStatus”:”complete”
    }
    }

 

Conclusion

Using the “Office 365 Users” connector, we can flag and unflag the email on the shared email box.

Thanks, and Enjoy the Coding & Results!

Leave a Reply

Your email address will not be published. Required fields are marked *