CRM Software Logo

Microsoft Dynamics 365 & Dynamics CRM experts provide reviews and opinions to aid professionals with the Dynamics 365 selection process.

 
 
ACE Microtechnology

Send Dynamics 365 Emails from Power Automate

Email | Print

Aaron Back, Microsoft MVP

Setting the stage

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...


Aaron Back is a Microsoft MVP with many years' experience with Microsoft Dynamics 365 (CRM), Power Apps, Power Automate (Flow), and Power BI. He is actively involved with the Microsoft Dynamics 365 UG (D365UG) (User Group) Community. His involvement includes: Serving as Chapter Leader for his local D365UG Chapter, serving on the D365UG Board of Advisors, and speaking at the annual D365UG Summit conference.


ACE Microtechnology, Inc. is a professional services firm committed to delivering Dynamics 365 (CRM) business solutions to small and medium sized organizations. Our focus is on delivering products and services that improve our clients’ business operations. ACE has developed specialties in serving the lite manufacturing, distribution and the hospitality industry.

Rather than just building technology or implementing software, we deliver real business value through industry knowledge and understanding each client’s business. We make it our business to know your business.

For more information or assistance with Dynamics 365 (CRM) contact ACE!

4 Responses to “Send Dynamics 365 Emails from Power Automate”

  1. Stephen says:

    It appears, Flows created inside a Solution do not currently show as On Demand Flows on an entity record.

    And unfortunately party lists are not supported on the CDS connector outside a solution.

    Completely broken Microsoft.

  2. Thank you very much for your article. I struggled with the standard Dynamics 365 and CDS connectors for many days until finding your article. I am very grateful.

    Are we able to send emails from a QUEUE? We have a shared mailbox we wish to send emails from. I created a Queue for it and have enabled and tested the Mailbox. However, the Power Automate flow throws an error saying there is no relationship between queues and activity parties. What solution is there to send emails from a Shared Email address?

  3. Ben Girard says:

    Amazing article!! Thanks for taking the time to create it. Been wanting to setup such a process for a long time, but never thought CDS/Flow would get there.

    I’m struggling with adding the To and From field in the email. I have followed your instructions, but I cannot find where to create the Activity Party Attributes. The screenshot is cropped too tight.

    I’d love to hear back from you…Thanks.

    • Ben – The Activity Party fields should appear when you choose “Email Messages” as the “Entity name”. There is a drop-down for the attributes to choose the “From” and “To” and “CC”. If you aren’t seeing these field options, click on the small “T” icon to the right of section. This will toggle between the JSON layout and the field layout.

      The values to enter into the Activity Party fields are pulled from the prior Power Automate steps. These in put in using the Dynamic Content option. Also, be sure to include the Schema name of the entity as a prefix and the Dynamic Content GUID in between the parentheses.

      I would suggest you test things with a single Activity Party, such as “TO”, to ensure things are working. Keep in mind that the root functionality will the same as using the “classic” workflows in Dynamics 365. You will need to be sure that you have an outbound email (“FROM”) that is set up with the Mailbox Tested & Enabled. Lastly, if you are using a true User Account and not a Queue account, then the User will need to have the Personal Options checked for “Allow other Microsoft Dynamics 365 users to send email on your behalf”.

Ask This Expert a Question / Leave a Comment

 

 
 
Show Buttons
Hide Buttons