“I’d like to automatically create a contact in Outlook contacts from an incoming email but it’s creating duplicates, how can I check if such contact already exists in Power Automate flow?”
One of the biggest benefits of Power Automate is the integration with the other M365 tools, e.g. Outlook. You receive an email with a specific subject, and additionally to some automated processing you can also add the sender to your contacts list. But you don’t want to create a new contact for each email from a sender. The contact should be created only with the first email, meaning you should always check if the contact already exists.
How do you do that in Power Automate flow, how to find a contact by an email address?
Search for a contact
The ‘Get contacts’ action offers you similar Filter Query possibilities as the SharePoint ‘Get items’ action. You define the property, operator, and the value to search for. For example, to look for a contact using the contact name and surname.
Note: you can see all the available columns if you run the action without any filter and then check the output.
Such Filter Query will work for all the simple columns, but it won’t work for the email address. The problem is that email addresses are always an array of objects with the emails inside.
Use the ‘any’ operator
In these situations you must use the ‘any’ operator in the OData Filter Query. The syntax in Power Automate is as below.
Search in the emailAddresses…
… in any of the objects …
… where the object property address …
… equals to a specific email address.
emailAddresses/any(a:a/address eq 'firstname.lastname@example.org')
You can use Power Automate to check if somebody with an email address already exists in your Outlook contacts, but you’ll need a bit more advanced Filter Query. Due to the structure of Outlook contacts you can’t just compare two values, you’ll need the ‘any’ operator in the Filter Query to get to the emails. After that it’s just the standard condition if anything was found.