{"id":4572,"date":"2024-02-25T08:49:10","date_gmt":"2024-02-25T08:49:10","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=4572"},"modified":"2024-02-25T08:52:46","modified_gmt":"2024-02-25T08:52:46","slug":"leveraging-sendemailfromtemplate-to-send-emails-to-unresolved-addresses","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=4572","title":{"rendered":"Leveraging SendEmailFromTemplate to Send Emails to Unresolved Addresses"},"content":{"rendered":"<p><strong>Introduction<\/strong><br \/>\nWhile working on Dynamics 365 CE we often need to streamline communication processes using Power Automate. While we want to send emails to our customer, one effective way to do this is by using email templates. Email templates streamline the communication process by providing users with a standardized framework for creating emails, ensuring brand consistency and saving time. These templates can be personalized with dynamic content, such as recipient names, organization details, or specific messaging, making them versatile tools for various communication scenarios. In our last two posts we discussed of using email template and how to bring related entity attribute and place them in the email body, you find links below, In this blog post, we&#8217;ll explore how to leverage SendEmailFromTemplate to send emails to unresolved addresses using Power Automate.<\/p>\n<p><strong>Details<\/strong><br \/>\nLet&#8217;s say in Dynamics 365 CE we want to send email to unresolved email addresses, which means there is not record in Dynamics 365 CE which having these email address. To send email to unresolved email address first we need to enable below setting under Email, so navigate to Settings-&gt;Administration-&gt;System Setting and enable it.<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4574 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail1-300x173.png\" alt=\"sendemail1\" width=\"300\" height=\"173\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail1-300x173.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail1-1024x591.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail1-624x360.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail1.png 1264w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Let&#8217;s assume in our Event custom entity we have field called External Recipients field where we have some unresolved email address used, it&#8217;s a text field so that user can enter multiple email address in the following format: test@test.com;test123@test.com<br \/>\nWe have setup a Queue in our system &#8216;Do Not Reply&#8217; from where we will sending email to these unresolved email address and as discussed in earlier posts we are using email template to create this email so let&#8217;s start creating our power automate.<\/p>\n<p>We want to send email when event is created so let&#8217;s add a trigger when new record is added to event and initialize variables like below to store external recipients emails, queue id and party list array:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail3.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4576 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail3-300x159.png\" alt=\"sendemail3\" width=\"300\" height=\"159\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail3-300x159.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail3-1024x543.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail3-624x331.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail3.png 1138w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nNext we need to add list action to get Queue and Email Template based on the name, while we have it, we can set Queue id using expression like in below screenshot.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail4.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4578 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail4-300x121.png\" alt=\"sendemail4\" width=\"300\" height=\"121\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail4-300x121.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail4-1024x413.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail4-624x252.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail4.png 1112w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nOnce we have queue id, we will append this under from partylist.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail5.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4579 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail5-300x248.png\" alt=\"sendemail5\" width=\"300\" height=\"248\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail5-300x248.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail5-624x516.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail5.png 828w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nIn the Compose action, I am suing split function <strong>split(triggerOutputs()?[&#8216;body\/him_externalrecipients&#8217;],&#8217;;&#8217;)<\/strong> and after that we are setting output to the external recipient email array.<\/p>\n<p>Once we have email addresses, we need to setup to partylist.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail6.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4580 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail6-300x163.png\" alt=\"sendemail6\" width=\"300\" height=\"163\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail6-300x163.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail6-624x339.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail6.png 811w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>And finally we need to use <strong>SendEmailFromTemplate <\/strong>action to send email using template we fetched and create email like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail7.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4581 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail7-300x155.png\" alt=\"sendemail7\" width=\"300\" height=\"155\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail7-300x155.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail7-624x323.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail7.png 801w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nAnd when we will test it, it will generate email like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail8.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4582 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail8-300x209.png\" alt=\"sendemail8\" width=\"300\" height=\"209\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail8-300x209.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail8-1024x713.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail8-624x435.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/sendemail8.png 1054w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>Summary<\/strong><br \/>\nWe learned how to utilize Dynamics 365 CE templates to send emails to unresolved addresses. By following the steps outlined in this blog post and leveraging the capabilities of Power Automate, you can streamline communication processes and ensure that important messages reach their intended recipients effectively.<\/p>\n<p>Hope it will help someone !!<br \/>\n<strong>Keep learning and Keep Sharing !!<\/strong><\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/?p=4541\">Creating Email Template for Custom Entities in Dynamics 365 CE<\/a><br \/>\n<a href=\"https:\/\/himbap.com\/blog\/?p=4562\">Getting Additional Fields from Lookup while using Email Template<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction While working on Dynamics 365 CE we often need to streamline communication processes using Power Automate. While we want to send emails to our customer, one effective way to do this is by using email templates. Email templates streamline the communication process by providing users with a standardized framework for creating emails, ensuring brand consistency and saving time. These&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=4572\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":4581,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,402,522,593,891,728],"tags":[1074,1076,1077,1075],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4572"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4572"}],"version-history":[{"count":6,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4572\/revisions"}],"predecessor-version":[{"id":4586,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4572\/revisions\/4586"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/4581"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}