Learn how to send email from Warp 10 using Microsoft Graph.

This post will show how to send an email from Warp 10 with Microsoft 365 accounts, using Microsoft 365 API called Microsoft Graph. From Warp 10 (since v3.x), we will use HTTP and CAPADD.
Introduction
The article will be split into three parts:
- Office365 Configuration
- Warp 10 Configuration
- Warpscript
What is Microsoft Graph?
Microsoft Graph is the gateway to data and intelligence in Microsoft 365. It provides a unified programmability model that you can use to access the tremendous amount of data in Microsoft 365, Windows, and Enterprise Mobility + Security.
Use the wealth of data in Microsoft Graph to build apps for organizations and consumers that interact with millions of users.
Office365 Configuration
This configuration is an example, the configuration can changed following your company policies. To follow the configuration you need to:
Go to: entra.microsoft.com
In the search bar: App registrations
Select: App registrations
New registration:
- Put a Name: W10SendMail
- Choose your account Type
- Let Url empty
- Subscribe
Under Manage in the APP registration tab:
- Go to Authorized APIs
- Using (…), remove permission User.Read
- Add a new permission
- Select Microsoft Graph
- Select app permission
- Mail / Mail.Send (Send mail as any user)
- Here you need to Grant admin consent (screenshot below)
- Go to Certificates & secrets
- New secret
- Add Description / Expiration Date (Max period = 2 years)
- WARNING: you must copy the value and save it somewhere safe: it will be called client_secret
- Go to Overview and Copy:
- Application (client) ID: it will be called client_id
- Directory (tenant) ID: it will be called tenand_id
Warp 10 configuration
Config file
In our WarpScript we are going to use HTTP which is part of the io.warp10.script.ext.http.HttpWarpScriptExtension extension.
To activate it, you need to add these lines to your /opt/warp10/etc/conf.d/99-custom.conf:
The second line above will be useful because we need at least two requests in order to send an email.
Restart Warp 10 (if you setup a systemd unit).
sudo systemctl restart warp10.service
Token
Since 3.0.0, HTTP is protected by HTTP capability, make sure you have created a token with the correct capabilities. For our case, you can find below a demo-tokengen.mc2.
Learn more about the use of tokens in Warp 10. |
WarpScript
Using Microsoft Graph documentation sendMail, need a Bearer {token}.
We need first to ask for a valid Token: Documentation & PostMan Example.
Let's do it with Warpscript:
Conclusion
You can now use Warp 10 to send emails with your Microsoft 365 portal. Please be aware that through Microsoft Graph, you can do much more operations than sending mail.
Read more
Building a Data Historian based on OPC UA, Warp 10, and Telegraf
Conversions to Apache Arrow format
2022 review of the Warp 10 platform

Digital Innovation Manager
— Guest author —