Sending DataVerse Emails in Power Automate Flow

Flow has the Outlook connectors for sending emails, from a shared mailbox or an individual account. But when using these, they are not connected into DataVerse, and it’s generally better to have any emails visible through the underlying app.

If your app is built on DataVerse, then don’t use the Outlook connector, use the built in DataVerse connector.

First up, the entity in DataVerse needs to be enabled for activities.

Then, you can send and receive emails from this entity, and set emails (and other activities) to be regarding this entity, or more specifically a record in this entity. This allows you to set up the form to show the related emails for a record:

In the app itself, there will now be an option to send an email from the record, which will automatically log that email against that record:

Now how to do this from Flow.

There are 3 steps required.

  1. Set up the activity parties; this is a Dynamics era term for users/contacts in the to, from, cc etc. fields.
  2. The DataVerse action Add a new row to the table Email Messages.
  3. The DataVerse action Perform a Bound Action again on the table Email Messages, with an action of SendEmail.

Setting up activity parties. For full details see the MS developer doc on activity parties. As the from:s and to:s will generally be dynamically generated, I suggest to use an array to hold the values.

The two terms needed to know are the participation mask (from, to, cc etc.), and the partyid which is the GUID of the contact / user etc. the email is going to.

A participation mask of 1 is the from (sender), and 2 is the recipient (to). The partyid needs to refer to the entity of the user/contact with the appropriate GUID. In the snippet below, I am sending from a user account where userFrom is the GUID of that user.

It could be the contact entity or a custom entity if required. To set up the to is the exactly the same, but with a participation mask of 2 (or 3 for cc, 4 for bcc)

participationtypemask": 1,
"partyid@odata.bind": "systemusers(⁠userFrom⁠)"

So a full activity party might look like this:

"participationtypemask": 1,

"partyid@odata.bind": "systemusers(⁠userFrom⁠)"
"participationtypemask": 2,
"partyid@odata.bind": "systemusers(⁠userTo⁠)"
"participationtypemask": 3,

partyid@odata.bind": "systemusers(⁠userCC)"

A queue can also be used for sending emails; a post for another day, but very useful if the emails should not come from an individual.

An example Flow below, using the simpler method of adding activity parties. Here the GUIDs of the system users (the DataVerse user GUIDs, not the Azure GUIDs).

The Add a new row to Email Messages expanded out. This is the easier way of adding the To / From fields – for more complex needs, use the participation mask code above.

and the email is related to the appropriate record as below to the contacts entity:

The simple solution is available is on my GitHub.

1 Comment

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s