Send email (Microsoft Graph)
The “Send email (Microsoft Graph)” service task sends HTML emails via the Microsoft Graph API. You define recipients, subject, body, and attachments – ideal for automated notifications.
Input parameters
Provide the following fields as task input:
{
"credentials": {
"tenantId": "b0e1b1b0-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"oAuthClientID": "1b1b1b1b-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"clientSecret": "1b1b1b1b-1b1b-1b1b-1b1b-1b1b1b1b1b1b"
},
"emailMessage": {
"subject": "Status update for your order",
"contentHTML": "<p>Hello Mr. Sample,</p><p>Your order has been completed successfully.</p>",
"toRecipients": [
"max.sample@example.com"
],
"attachments": [
{
"name": "Invoice.pdf",
"fileReference": "s3://bucket-name/invoice.pdf"
}
]
},
"userFrom": "noreply@pantarey.io"
}
Explanation:
credentials
: Credentials for the Microsoft Graph API.emailMessage
: Contains subject, body, recipients, and attachments.userFrom
: Sender address.
Output
The task returns the status of the email delivery.
{
"status": 200,
"response": {
"messageId": "1234567890",
"timestamp": "2024-12-22T10:00:00Z"
}
}
Explanation:
status
: HTTP status code (200
indicates success).messageId
: Unique ID of the sent message.timestamp
: Time of delivery.
JSONata examples
{
"emailMessage": {
"subject": "Status for order {{$.orderDetails.orderId}}",
"contentHTML": "<p>Hello {{$.customer.name}},</p><p>Your order no. {{$.orderDetails.orderId}} has been completed.</p>",
"toRecipients": [
"{{$.customer.email}}"
],
"attachments": [
{
"name": "Invoice_{{$.orderDetails.orderId}}.pdf",
"fileReference": "{{$.attachments.invoice}}"
}
]
}
}
Notes
- Use HTML to design engaging messages.
- Ensure that
credentials
are valid so Microsoft Graph can be reached. - Attachments are referenced via file references (e.g., from S3).
Tip
Test JSONata expressions in the JSONata Playground before using them in production.