TK
Why Use This Method?
In ARIS Cloud, the default mail server is often predefined. However, you may want to connect to an external mail server for various reasons:
- Security compliance (e.g., using a centralized corporate mail server)
- Custom email handling and integration with other systems
- Flexibility in choosing your mail service provider
The following script will allow you to bypass the internal mail server by connecting to Microsoft Graph API directly.
Requirements
To implement this script, you'll need the following:
- Microsoft Azure App Registration: Create an app and register it in Azure AD to get your OAuth credentials.
- Microsoft Graph API Permissions: Grant appropriate permissions to your Azure app to send emails.
- ARIS Scripting Environment: We are using JavaScript (Rhino) in ARIS to perform the authentication and API call.
Script Overview
Here is a JavaScript code that can be embedded in ARIS to send emails using Microsoft Graph
- see Attachment
Explanation of the Code
- Obtain Access Token (OAuth2): The script first requests an OAuth2 access token from Microsoft Identity Platform using the
client_credentials
grant type. The access token is then used to authenticate subsequent requests to the Microsoft Graph API. - Sending the Email: Once we have the access token, the script constructs an email object and sends it via the Microsoft Graph
sendMail
API. The API accepts a JSON payload containing the email's subject, body, recipient, and other details. - Using Rhino: ARIS uses Rhino (a JavaScript engine for Java) for scripting, so we leverage Java's networking libraries to make HTTP requests.
How to Implement This in ARIS
- Open your ARIS Script Editor.
- Copy the script into your ARIS environment.
- Replace the placeholder values (client ID, secret, email addresses, etc.) with your actual details.
- Execute the script to send an email.
Conclusion
This method offers an alternative to using the built-in mail server of ARIS Cloud, providing flexibility for email delivery. With the OAuth2 and Microsoft Graph setup, you gain full control over your email service while maintaining security and compliance.
If you encounter any issues or have questions, feel free to leave a comment below!