Forum Discussion

djcris's avatar
djcris
Copper Contributor
Apr 28, 2023
Solved

[Teams] Adaptive card opens outlook email template

Hello!

 

I'm currently developing a command bot that would display some information after the user types a command. I've successfully deployed my bot to azure environment via the teams-toolkit 5.0 at the moment I'm seeking to add some extra functionality.

 

  • Feature to add: Sometimes my information would contain and email address and I would like to use that email address to open Outlook and create an email template, like we do when we call "mailto:email address removed for privacy reasons".

I've done some research in the documentation and I'm not sure if this is even possible?:

https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/universal-actions-for-adaptive-cards/overview?

If someone has an example of this working that would be greatly appreciated!!



  • djcris 

    Yes, you can create an adaptive card that, when clicked, opens an Outlook email template. Here's how you can do it:

    1. Create an adaptive card that includes a button element. Here's an example JSON code for an adaptive card with a button element:
    { "type": "AdaptiveCard",
    "body": [
    { "type": "TextBlock",
    "text": "Click the button to open an email template." }
    ],
    "actions": [
    { "type": "Action.OpenUrl",
    "title": "Open Email Template",
    "url": "mailto:email address removed for privacy reasons?subject=Example%20Subject&body=Example%20Body"
        }
      ]
    }
    1. In the actions array, specify the type of action as Action.OpenUrl. This action allows you to specify a URL to open when the button is clicked.
    2. In the url field, specify the mailto: protocol followed by the email recipient's email address, subject, and body. You can use URL encoding to encode spaces and special characters in the subject and bodyhttps://www.gotravelaindonesia.com/

    When the user clicks the button in the adaptive card, it will open a new email message in Outlook with the specified recipient, subject, and body.

3 Replies

  • Faisal1775's avatar
    Faisal1775
    Brass Contributor

    djcris 

    Yes, you can create an adaptive card that, when clicked, opens an Outlook email template. Here's how you can do it:

    1. Create an adaptive card that includes a button element. Here's an example JSON code for an adaptive card with a button element:
    { "type": "AdaptiveCard",
    "body": [
    { "type": "TextBlock",
    "text": "Click the button to open an email template." }
    ],
    "actions": [
    { "type": "Action.OpenUrl",
    "title": "Open Email Template",
    "url": "mailto:email address removed for privacy reasons?subject=Example%20Subject&body=Example%20Body"
        }
      ]
    }
    1. In the actions array, specify the type of action as Action.OpenUrl. This action allows you to specify a URL to open when the button is clicked.
    2. In the url field, specify the mailto: protocol followed by the email recipient's email address, subject, and body. You can use URL encoding to encode spaces and special characters in the subject and bodyhttps://www.gotravelaindonesia.com/

    When the user clicks the button in the adaptive card, it will open a new email message in Outlook with the specified recipient, subject, and body.

    • djcris's avatar
      djcris
      Copper Contributor
      Thank you for that example!

      I still for some reason have an strange instance where teams on the web would become unresponsive after I click on the "Open Email Template" button, but it won't crash on the desktop app.

      Any ideas?

Resources