cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MB-HealthSci
Regular Visitor

Re: Using Power Automate to send an Adaptive Card-Based Email through Outlook

Greetings @VJR,

 

I wanted to provide a late update.  I was successful in creating a cloud based flow using the "Compose" action into which I pasted the adaptive card template.  Now, I have an adaptive card-based email with a user-specific attachment which seems to be working (which was the goal).  Thanks again for the help!

 

May I ask a related question?  When exploring the formatting of the adaptive card, initially I used the FactSet container to communicate the needed information (which renders well).  Because the FactSet container is somewhat limited in formatting (I do not believe one can adjust the width of the FactSet "title", "value" pairs), I experimented with the "Table" container.  Interestingly, even when using the adaptive card designer (https://adaptivecards.io/designer/), and copying the example card template code (within the Schema Explorer page) for tables (https://adaptivecards.io/explorer/Table.html) into a "New Card" (blank card), the message that is generated reads "[Parse] Unknown element type "Table".  Fallback will be used if present".  I find it interesting that the Schema Explorer code, when directly copied and pasted, does not even render within the adaptive card designer.  As expected, when I tried the Table container within my cloud flow it failed to render.  I believe the reason is due to the host app schema version.  It appears Table containers are only recognized by version 1.5 and yet the Bot Framework Web Chat and Microsoft Teams apps (which have the highest Schema Versions in the "Select host app" list) are only at 1.4.  May I ask if this is an issue you have been exposed to, and if this implies  Tables simply are not capable of being rendered until the host app versions increase (I hope my question makes sense, and my apologies if it doesn't)?

 

The example code from the Table Schema Explorer is:

 

 

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5",
    "body": [
        {
            "type": "TextBlock",
            "text": "Table with gridlines",
            "wrap": true,
            "style": "heading"
        },
        {
            "type": "Table",
            "columns": [
                {
                    "width": 1
                },
                {
                    "width": 1
                }
            ],
            "rows": [
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "showGridLines value",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Behavior",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        }
                    ]
                },
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "true",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Cells are separated by 1px width gridlines",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        }
                    ]
                },
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "false",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Cells are separated by the cell spacing value configued in hostconfig",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        }
                    ]
                }
            ]
        },
        {
            "type": "TextBlock",
            "text": "Table without gridlines",
            "wrap": true,
            "style": "heading"
        },
        {
            "type": "Table",
            "columns": [
                {
                    "width": 1
                },
                {
                    "width": 1
                }
            ],
            "rows": [
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "showGridLines value",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Behavior",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        }
                    ]
                },
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "true",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Cells are separated by 1px width gridlines",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        }
                    ]
                },
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "false",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Cells are separated by the cell spacing value configued in hostconfig",
                                    "wrap": true
                                }
                            ],
                            "style": "accent"
                        }
                    ]
                }
            ],
            "showGridLines": false
        }
    ]
}

 

 

Thanks again, and my apologies for being quite slow.

 

-matt

 

10 REPLIES 10
MB-HealthSci
Regular Visitor

I am using Power Automate (PA) Desktop to send emails to a variety of staff based on data contained in an Excel file.  To achieve the desired email formatting, I am attempting to use an adaptive card template.  The data for the template is being filled from the previously mentioned excel file.  I am using the 'Send email message through Outlook' action to compose and send the email.  In the "Body" field, I have copied and pasted the JSON template with the defined excel data variables (inside %%):

 

 

 

<script type="application/adaptivecard+json">
{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "TextBlock",
      "size": "Medium",
      "weight": "Bolder",
      "text": "Weekly At-Risk Students Report"
    },
    {
      "type": "ColumnSet",
      "columns": [
        {
          "type": "Column",
          "items": [
            {
              "type": "Image",
              "style": "Person",
              "url": "${creator.profileImage}",
              "size": "Small"
            }
          ],
          "width": "auto"
        },
        {
          "type": "Column",
          "items": [
            {
              "type": "TextBlock",
              "weight": "Bolder",
              "text": "%name%",
              "wrap": true
            },
            {
              "type": "TextBlock",
              "spacing": "None",
              "text": "For Week Of: TEST",
              "isSubtle": true,
              "wrap": true
            }
          ],
          "width": "stretch"
        }
      ]
    },
    {
      "type": "TextBlock",
      "text": "Please see the at-risk student information below:",
      "wrap": true
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Instructor:",
          "value": "%name%,"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Email:",
          "value": "%email%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Attachment Location:",
          "value": "%filepath%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Number of Students:",
          "value": "%nstudents%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "At-Risk Students:",
          "value": "%narn%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Notes Submitted:",
          "value": "%narn%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Notes Needed:",
          "value": "%narnn%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Unsubmitted Assignments:",
          "value": "%nua%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Late Graded Assignments:",
          "value": "%nlgar%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Days Since Last Canvas Access:",
          "value": "%ndslcacc%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Days Since Last Canvas Activity:",
          "value": "%ndslcactive%"
        }
      ]
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.5"
}
</script>

 

 

 

 Even with the "Body is HTML" slider (within the 'Send email message through Outlook' action) slid to the TRUE position, upon running the flow I find the JSON object is not rendered (the email is blank).  The documentation led me to believe that following the line, "<script type="application/adaptivecard+json">," the following JSON should, in fact, be rendered. Since I am quite new to the power apps and to adaptive cards, my hope is that the error I am making is common and therefore easy to find.  For those of you with experience sending adaptive cards using PA, may I ask if you can spot the syntactic or logical error?

 

Thank you very much for any help in the right direction, and if you need any additional information please feel free to let me know.

 

-matt

Maybe you need <html> tags surrounding everything? 🤷‍♂️

Thanks for the suggestion @Henrik_M !  

 

I added in the opening and closing <html> tags (copied below for completeness), however unfortunately Outlook is not rendering the JSON still.

 

 

<html>
<script type="application/adaptivecard+json">
{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "TextBlock",
      "size": "Medium",
      "weight": "Bolder",
      "text": "Weekly At-Risk Students Report"
    },
    {
      "type": "ColumnSet",
      "columns": [
        {
          "type": "Column",
          "items": [
            {
              "type": "Image",
              "style": "Person",
              "url": "${creator.profileImage}",
              "size": "Small"
            }
          ],
          "width": "auto"
        },
        {
          "type": "Column",
          "items": [
            {
              "type": "TextBlock",
              "weight": "Bolder",
              "text": "%name%",
              "wrap": true
            },
            {
              "type": "TextBlock",
              "spacing": "None",
              "text": "For Week Of: TEST",
              "isSubtle": true,
              "wrap": true
            }
          ],
          "width": "stretch"
        }
      ]
    },
    {
      "type": "TextBlock",
      "text": "Please see the at-risk student information below:",
      "wrap": true
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Instructor:",
          "value": "%name%,"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Email:",
          "value": "%email%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Attachment Location:",
          "value": "%filepath%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Number of Students:",
          "value": "%nstudents%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "At-Risk Students:",
          "value": "%narn%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Notes Submitted:",
          "value": "%narn%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Notes Needed:",
          "value": "%narnn%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Unsubmitted Assignments:",
          "value": "%nua%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Late Graded Assignments:",
          "value": "%nlgar%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Days Since Last Canvas Access:",
          "value": "%ndslcacc%"
        }
      ]
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "$data": "${properties}",
          "title": "Days Since Last Canvas Activity:",
          "value": "%ndslcactive%"
        }
      ]
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.5"
}
</script>
</html>

 

Still, I most certainly appreciate the suggestion!

-matt

Hi @MB-HealthSci 

 

I don't think json can be rendered when html is passed.

You might want to use a json to html converter to find the corresponding html and then modify as per requirement.

 

 

 

I tried converting the json you shared on both these links and was seeing some kind of output. 

PS: I had to remove the <script> tag because again it is html and not Json.

Thank you @VJR for taking the time to look into this!

 

Since I believe the goal to utilize the adaptive card, since after all adaptive cards can include actionable message elements, I am not sure if a pure html email can truly serve the same purpose (perhaps it can, however, my limited understanding is that the cross-platform formatting compatibility adaptive cards deliver, along with the actionable message potential is at least much more difficult to realize with html alone).  

 

Perhaps I am approaching the problem incorrectly.  The goal would be to use Power Automate (PA) to build recipient-specific adaptive cards (using the Excel data) and share that adaptive card through Outlook.  In the "big picture," may I ask if you are aware of how feasible it is to realize the idea this way?   Perhaps Outlook is the wrong PA action.  Perhaps there is another action that is better fit for the construction and dissemination of the adaptive card?  I should say that I have a colleague who was able to render JSON in Outlook using web-based PA.  In her case, she used the "Compose" item and pasted the JSON object into it (followed by utilizing the compose variable within the Outlook message construction).  In PA-Desktop, however, there is no "Compose" item/action.  I have tried pasting the JSON as a "Variable" item, however this attempt failed as well. 

 

Thank you again for taking the time to look into this!

 

-matt

Hi @MB-HealthSci 

 

I have gone through your entire message.

 

- That was my first instinct when I read the original post ie; to use Cloud flows because it has more integration options for adaptive cards. So is there any specific reason that you are using Desktop flows and not Cloud flows?

 

-  If you can print and share what was the input and output of the Compose action, we could think of seeing what are the similar possibilities in PAD.

Thanks again @VJR ,

 

My apologies for the delay.  I have not used cloud flows before, and I am finding it takes more time than expected to learn what feels like a nearly completely different app.  I am struggling to figure out how to reattach my user-specific attachments to my cloud flow, however once I have been able to fully reproduce what I have been able to do with my desktop client flow, I then will venture into the adaptive card territory.  

Again, and again, thank you for your help, and my apologies for the delay (the learning slope of the learning curve is rather steep, and apparently slippery).

 

-matt

VJR
Multi Super User
Multi Super User

Hi @MB-HealthSci , I have moved your post from Desktop flows to cloud flows. But I suggest you close this one and submit a new one here according to your latest situation so that you can get accurate help.

ivan_wilson
Advocate II
Advocate II

Have a look at the guide here. I believe you need to define a separate <head> and <body> in your HTML. The <script> tag goes into the <head> tag. 

 

I have successfully sent an adaptive card using A Power Automate cloud flow with the "Send Email (v2)" action. You should send the message to yourself to test. If you want to send to another user, you will need to go through additional steps, otherwise the card won't be rendered.

brianna1
New Member

Hi there, I know it's been an age since you posted your question, but I am having a similar problem and I'd love to know how you solved yours. I am trying to put excel data into a table and send an adaptive card (teams not email) however I can't get the info from excel into the card. I have three columns and 12 rows including headers. Column A is text, the next three columns are times hh:mm:ss format.

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (4,156)