Task: Send HTML email though Dynamics 365
Difficulty: Advanced
Time to implement: 1-2 hours
Tracking emails is a popular feature in Dynamics 365 Customer Engagement. You can track emails by connecting your mailbox with Microsoft Exchange and either use the Dynamics 365 app for Outlook or Dynamics 365 email capabilities to send out emails. Companies see great value in this feature because it allows them to have a CRM system in place where relevant interactions between a customer and an organization can be observed.
In this post, I am going to show you how to use the Dynamics 365 emails and discuss some of its benefits and limitations in terms of functionality. Dynamics 365 emails are equipped with a simple email editor for creating emails. The editor covers the basic requirements for what you would normally use when sending an email from your email client such as Gmail or Outlook.

Dynamics 365 emails allow you to send emails to multiple recipients, add attachments, insert links and images. However, if you want to create your own HTML email you cannot do that through Dynamics 365 emails. This could be useful in scenarios where the company wants to send out a promotional emails, e.g. because there is a new product release or an event. Dynamics 365 does not support HTML emails.
On the other hand, if you like to send HTML emails through Dynamics 365 there is a workaround. By leveraging Power Automate and the Dataflex (CDS Current enviornment) connector, you can create a workflow that creates and sends an email with HTML content.
For example, you have a lead that you would like to send an event invite to. You can achieve this by creating a flow in Power Automate and use a field on the lead to trigger the flow. The salesperson could simply check a box on the lead form to send the invitation. Furthermore, the email would be automatically tracked in Dynamics 365. This gives the salesperson and her manager a better overview of who has received an invitation to an event.
In the remainder of this post I will show how you can create and send a HTML email through Dynamics 365 Sales with the help of Power Automate.
1. Create the flow
- You start by navigating to make.powerapps.com and create a solution for your Flow. For information on how to create a solution in Power Apps please refer to this article.
- Click on the ‘+New’ button and select Flow

- Search for and select the Dataflex ‘When a record is created, updated or deleted’ trigger (Common Data Service current).
- Give your Flow a name.
2. Configure the flow
Once you have created the flow you can define the entity name, the type of trigger condition as well as the filtering attribute for the newly created trigger. In this case we have created a custom field which will serve as the trigger for this flow or the filtering attribute.
- In trigger condition choose Update.
- In the entity name choose Leads.
- For the Scope select Organization.
- In the filtering attribute write the name of your custom field.

Next we need a variable to store our HTML. To do this we:
- Click on the ‘New Step’ button.
- Select Initialize variable.
- Give our variable a name and choose type string. Leave the value field empty.

Before we set the variable you first want to check if our field value meets the condition.
- Click on the ‘New Step’ button.
- Select control.
- Choose control condition.
- For the condition choose the custom field and that it should be equal to ‘true’. The field is a two option field which can be either true (1) or false (0).

When the condition is true you want the email to be sent. First you need to set the variable we created in our previous step and then you will create the email. Lastly you want to send the email message using a bound action.
- In the ‘If yes’ box click ‘Add an action’.
- Choose Set variable.
- In the name select the variable you initialized in steps 2.6-2.7.
- In the value field paste in your HTML code.

Now you have created the condition and set the variable. This leads to the creation of the email message. To create the message you:
- Below the ‘Set email content’ action click ‘Add an action’.
- Choose Create a new record – Dataflex (Common Data Service current).
- For the email message choose the sender and receiver of the message. You must refer to the entity’s path as shown in the following screenshot. For more info about how this connector’s attributes are referenced see this article.

- Click ‘Show advanced options’ and add the email body to the ‘Description’ field, owner in the ‘Owner (Owners)’ field, the lead (‘/leads/{the lead GUID value}’) in the ‘Regarding (Leads)’ field, and the subject in the ‘Subject’ field.
The final step is to send the email. This requires a special kind of action called a bound action. To see the difference between bound and unbound actions please refer to this article.
- Below the ‘Create a new record’ action click ‘Add an action’.
- Choose Perform a bound action – Dataflex (Common Data Service current).
- In the Entity name choose Email Messages
- For the Action Name choose SendEmail.
- In the Item ID insert the Email Message ID. You find the ID by using the dynamics content and choosing the unique ID of the email message you created in steps 2.16-2.19 above.
- In the IssueSend select Yes.

3. Test the flow
You can now test your flow to see if everything works as it should. Do a test run on a lead in your Dynamics 365 Sales to verify that the flow runs when the custom field is changed on the lead and if the email is sent when the flow condition is true. For more information about performing the test, please refer to the blog post’s video above.