Power Apps  

How to Create Email Templates in Dataverse and Dynamically Populate Them Using Power Automate

Consistently managing email communication across environments is a crucial part of any enterprise application. Dataverse provides a built‑in Email Template entity, and Power Automate allows us to dynamically populate these templates and send personalized emails to users.

This article explains step-by-step how to:

  1. Create and store Email Templates inside Environment → Settings → Templates → Email Templates

  2. Retrieve those templates from Power Automate using the Dataverse connector

  3. Dynamically replace placeholder values in the Subject and Body

  4. Send automated emails using Power Automate

Part 1: Creating an Email Template in Dataverse

Step 1 — Navigate to Email Templates

  1. Open Power Apps → choose your Environment.

  2. Go to Settings (the gear icon in the top-right).

  3. Select TemplatesEmail Templates.

    1

Step 2 — Create New Template

  1. Click + New Template

  2. Choose the category (e.g., Global Template, or entity-specific like Contact, Account, etc.).

  3. Provide details:

    • Template Name

    • Subject

    • Body (HTML allowed)

      2

Step 3 — Use Placeholder Variables

Inside subject/body, add placeholders you want to replace dynamically. Example:

Subject: Hello {{UserName}}, your request has been processed
Body:
Dear {{UserName}},<br><br>
Your ticket {{TicketNumber}} has been successfully approved.<br>
Regards,<br>
Support Team

These placeholders ({{UserName}}, {{TicketNumber}}) will later be replaced dynamically through Power Automate.

Step 4 — Save Template

Click Save & Close.

Your template now exists inside Dataverse Email Template table.

Part 2: Retrieve Template from Dataverse using Power Automate

Step 1 — Create a Flow

  1. Open Power Automate

  2. Choose Automated Cloud Flow

  3. Add a trigger (e.g., When a row is added, Recurrence, etc.)

Step 2 — Get Email Template from Dataverse

  1. Add step → DataverseList Rows

  2. Select Email Templates table (template table)

  3. Apply filter to fetch your template:

title eq 'Your Template Name'
  1. From output, select the first row (use first(body('List_Rows')?['value']) if needed).

    3

Step 3 — Extract Subject and Body

Map fields:

  • Subject → subject

  • Body → body

Part 3: Replace Dynamic Variables in Template

Power Automate does not auto‑replace placeholders, so we manually process them.

Step 1 — Add “Compose” Actions

Create two Compose actions:

Compose – Subject

replace(outputs('TemplateSubject'), '{{UserName}}', variables('UserName'))

Compose – Body

You can chain multiple replacements:

replace(
    replace(
        outputs('TemplateBody'),
        '{{UserName}}',
        variables('UserName')
    ),
    '{{TicketNumber}}',
    variables('TicketNumber')
)

Step 2 — Store Dynamic Values in Variables

Before using them in replace:

  1. Add Initialize Variable – UserName

  2. Add Initialize Variable – TicketNumber

  3. Populate values from Dataverse row or trigger.

4

Part 4: Send Email Using Power Automate

Option 1 — Using “Send an email (V2)” with Outlook Connector

  1. Add action: Outlook → Send an email (V2)

  2. To: user email

  3. Subject: output of Compose – Subject

  4. Body: output of Compose – Body

5

Final Flow Summary

  • ✔ Retrieve Template from Dataverse

  • ✔ Load Subject + Body into variables

  • ✔ Replace placeholders dynamically

  • ✔ Send email with updated content