Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to send an email template with an attachment dynamically?

Posted on by 873

Hello,


I wanted to know if it is possible to send an email template including an attachment dynamically by performing the unbound action "SendEmailFromTemplate" in Power Automate cloud flows.


This amazing blog post covers what I am looking for:
https://linnzawwin.blogspot.com/2022/10/generate-document-from-word-template.html?sc=1680760985532#c4723434891612517795


However, the only difference is that my email templates are in the "Email Template table" which already includes subject, body, and personalization variables included dynamically.

The below action can be used to create a draft email:
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/reference/instantiatetemplate?view=dataverse-latest

I am still stuck on how to build the below on Power Automate:

1. Creating Draft Email (From InstantiateTemplate action)

2. Creating the attachment and adding an attachment to the notes

3. Sending the email


Can you please show a small example of how to achieve that?


Any help is greatly appreciated.

EBMRay

  • Verified answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    RE: How to send an email template with an attachment dynamically?

    Hi EBMRay,

    Refer to the following steps to create draft Emails (From InstantiateTemplate action) in power automate:

    1.Get the email template ID you need:

    --My example email template:

    pastedimage1681191570477v2.png

    2.Perform an unbound action--InstantiateTemplate:

    pastedimage1681191785637v4.png

    --ObjectType: Logical name of the entity in the email template category

    --ObjectId: Email templates are based on which record is inserted(in my example, i want to apply template based on one contact(To field)--Leah Ju)

    pastedimage1681192236175v5.pngpastedimage1681192313116v6.png

    3.Compose--Get body of the action:

    pastedimage1681192427546v7.png

    4.Parse JSON

    https://www.m365princess.com/blogs/2021-02-08-how-to-use-parse-json-action-in-power-automate/ 

    pastedimage1681192514540v8.png

    {
        "type": "object",
        "properties": {
            "@@odata.context": {
                "type": "string"
            },
            "value": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "@@odata.type": {
                            "type": "string"
                        },
                        "subject": {
                            "type": "string"
                        },
                        "description": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@@odata.type",
                        "subject",
                        "description"
                    ]
                }
            }
        }
    }

    5.Add a new row

    --Apply to each action will be added automatically after setting subject and description

    pastedimage1681192596933v9.png

    pastedimage1681192655701v10.png

    Now you can add attachments and send emails on power automate (just as described in the first blog you provided).

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: How to send an email template with an attachment dynamically?

    Hello Steve Zhao2,

    I would highly appreciate your assistance regarding this topic.

    Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans