Send Dynamics 365 Emails from Power Automate

Sending
User Review
0 (0 votes)

Prior to Power Automate (formerly Microsoft Flow), many of you probably sent emails using a workflow in Dynamics 365. This option has been around for quite some time. Typically, you have some automated process where emails go out to notify internal personnel or external customers. But, you may have seen the “nag” message within the classic workflow screen (see the below screen shot).

Here is a simple example of the classic setup.
Classic workflow send email

The next step would be to customize the email message.
Classic workflow send email - update email message

Lastly, you would activate the workflow and all would be good to go. And, the great thing about this option is that the sent email will be saved as an Email Activity within Dynamics 365, and show up in the Timeline associated with the record.

Then there’s Power Automate

Power Automate now provides the same concept of sending Dynamics 365 emails. However, there are few things to be aware, and the setup is different.

First, you will need to create the flow from within a solution. If you are not familiar with this process, it’s pretty easy.

  • Navigate to https://flow.microsoft.com
  • Log in with your credentials
  • Click “Solutions” on the left
  • Click “New” at the top, give the solution a name and Publisher, and then save it. This will show the solution in the solution list.
  • Click on the new solution name to open it.

Power Automate - Create Solution

Second, you need to click the “New” and then “Flow” option at the top. This will launch a new tab/window within your browser to start building the flow.
Power Automate - Create flow within solution

The flow setup

Now that the flow screen is up, you will need to understand a few things. First, you will need to be sure you are using the “Common Data Service (current environment)” trigger. This trigger only has one action of “When a record is created, updated, or deleted”. But, it’s important to keep using this same connector throughout the flow for all the CDS actions.

Power Automate - CDS current environment trigger

Next, there some neat tricks to help you building the flow, and, subsequently, the email message.

Variables are your friends

If you haven’t used variables before (or compose), they are simple to set up in Power Automate and can be used multiple times. This comes in handy when you have long flows.

You will need to initialize a variable prior to setting the variable value. To find the variable actions, simply search for “variable”.
Power Automate - Search for variable actions

In the list above, the “initialize variable” is listed. Choose this option to start creating the variable.
Power Automate - Variable Email Message

The above screen shot shows a variable I set up which will allow a custom email message to be created. By using a variable, I can plug in dynamic content pulled from various steps in the flow.

For our example, I will keep this simple. The below screen shot shows a simple example of an HTML message.
Power Automate - Set variable Email Message

“To”, “CC”, and “From” flow items

If you consider the goal of the flow of sending a Dynamics 365 email, you will realize there are other items you need. The other items you may need are the “To”, “CC”, and “From”. Again, use the “CDS (current environment) connector” for these actions.

The “To” and “CC” recipients will need to reference some record(s) within Dynamics 365. Typically, this is a Contact record. The “From” is which account will be sending out the email. You may have a special account set up already that is sending out the classic workflow emails.

Here are simple “Get Record” actions for both the “To” contact and the “From” user.
Power Automate - Get contact record

Power Automate - Get the From user

Creating the email message

The next step is to create the email message you want to send out. If you have followed along so far, you should have some of the basic items needed to create the email message. This step will also create the Email Activity within Dynamics 365 and associate it with the correct record. Thus, recreating the classic process in Power Automate.

You will need to use the “Create Record” action and choose the “Email Messages” entity. Once you do this, the full action will load with many fields. For this reason, I will show just a few of the basic fields to get the record created.

Email Activity Parties

First, you will need to set up the Activity Party Attributes. If you have these ready, based on the above section, you can plug these into the fields as shown below. Something important to note is that if you have multiple “To” or “CC” recipients, you will need to add these as individual Activity Parties. As you can see below, there are 2 “CC” fields listed.

Second, in the example below, I have the “To” matched with a Contact associated with a Case. The “CC” is another contact that wants to be copied on the message. The “From” is the User account used for sending out the email message. The last “CC” is the Owner of the Case. This will keep the owner aware that a message went to the customer.

Power Automate - Create Email Message recipients

Email Description

The next field to update is the “Description”. This will be the body of the email. If you used the variable I recommended above, then you can use the Output of the variable as the Input for this field.

Power Automate - Create Email Message Description

Email Activity Regarding Record

Next, the Email Activity record needs to be linked (regarding) a record. In this scenario, it will be linked to a case record. For example, if the trigger of the flow is when a Case is assigned to someone (owner changes), then you can reference the Case GUID (unique ID) in the below field.

The reason for having “incidents(Case)” in the field, is that the regarding field needs an entity reference along with the GUID. The underlying name for the Case entity is “incidents”.

Email Subject

Now, the Subject of the email needs to be populated. You will notice I used another variable for this. However, you don’t need to do this. You can use plain text here if you want to keep things simple.

Power Automate - Create Email Message Subject

Sending the email

The last part of this process is to actually send the email. This is done using a the “Send Email” bound action that is part of the “CDS (current environment)” connector. Below is an example of this action.

Power Automate - Send Email Bound Action

This action has a few parts to cover.

  • Entity name – This is the entity that correlates to the same entity of the “create record” action. In that step we created an “Email Message” record.
  • Action name – There will be a drop-down list that corresponds to the “Entity name” chosen.
  • Item ID – This will be the GUID (unique ID) of the record to send. In this case, it will be the prior action of the “Email Message” record that was created.
  • IssueSend – This is a No/Yes option list. If this is set to “no”, the email will not send. Be sure you set this to “yes” for the email to send.

In Conclusion

While the Power Automate process may not be as straightforward as the classic workflow, it does open up other opportunities. It can allow more flexibility in the dynamic content, related records that can be referenced, and any conditions you may need.

Yes, Power Automate may seem intimidating at first if you haven’t used it before, but keep practicing. At some point the classic workflows may be deprecated, but this is unknown at this time. This is a topic for another time and place.

Until next time…