Send email from Handlebars template (Microsoft Graph)
The “Send email (Microsoft Graph) from template” service task automatically sends HTML emails whose content is built with the Handlebars templating language.
Input parameters
Provide the following fields as task input:
{
"credentials": {
"tenantId": "string",
"oAuthClientID": "string",
"clientSecret": "string"
},
"emailMessage": {
"subject": "string",
"contentData": { "key1": "value1", "key2": "value2" },
"contentTemplate": "<p>This is a test mail with placeholders {{key1}}</p><p>{{key2}}</p>",
"toRecipients": [
"receiver1@example.com",
"receiver2@example.com"
],
"attachments": [
fileReference1,
fileReference2
]
},
"userFrom": "email@example.com"
}
Explanation:
credentials
: Credentials for accessing Microsoft Graph.emailMessage
: Message definition with subject, recipients, template content, and optional attachments.userFrom
: Sender address.
Output
The task returns the email delivery status:
{
"status": 200
}
status
: HTTP status code of the delivery (200
/201
/202
indicate success).
JSONata examples
// Example 1: Set subject dynamically
{
"emailMessage": {
"subject": "Quote for " & $.customerName
}
}
// Example 2: Choose recipients based on a condition
{
"emailMessage": {
"toRecipients": $.isPreferredCustomer ? ["vip@example.com"] : ["default@example.com"]
}
}
Notes
- Use JSONata to adapt the input dynamically to process data.
- All required fields must be filled correctly for a successful delivery.
- On errors the task returns an appropriate status code.
Tip
Test JSONata expressions in the JSONata Playground before using them in your model.