EML File Generation

Content Type: Module
Categories: Utility,Data

Overview

This module helps to generate EML file using

  • Microsoft Graph API
  • Custom Java Action

Generate EML using Graph API:

Check the https://learn.microsoft.com/en-us/graph/outlook-get-mime-message

Permission to get mime message:

https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions

  • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret.
  • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded.

Generate EML using Java Action:

JA_GenerateEMLFile java action is used to generate the EML file

  • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it.
  • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the EML file.

Documentation

Typical usage scenario


EML File Generation produces .eml files — the standard single-message email format that Outlook, Thunderbird, and Apple Mail open natively — from inside your Mendix application. It offers two independent routes: build a message yourself from data in your app, or fetch the original

MIME message of an existing mailbox item through the Microsoft Graph API.


Use it when you need to:


- Archive correspondence against a record — store a copy of

what was sent alongside the order, case, or claim it belongs to, in a format

any mail client can open.

- Export an existing mailbox message — pull the exact

original MIME of an Outlook message by its ID through Microsoft Graph and hand

it to the user as a download.

- Produce an auditable evidence trail — keep the full

message including headers and attachments, rather than a rendered PDF or a

database summary.

- Hand users a draft to send from their own client

generate a prepared message with recipients, subject, HTML body, and

attachments that the user opens and sends themselves.

- Migrate or hand off email data — emit messages in a

portable, non-proprietary format when moving between systems.


It suits case management, claims handling, compliance, and

any back-office application where a durable record of an email matters.


Features and limitations


Two generation routes


- Custom Java action — JA_GenerateEMLFile builds an EML file

from data you supply in the app: From, To, CC, BCC, Subject, HTML body, date

sent, file name, and any number of attachments.

- Microsoft Graph API — retrieves the original MIME message

for an existing Outlook message by its message ID. See the Microsoft Graph

documentation

(https://learn.microsoft.com/en-us/graph/outlook-get-mime-message).


Attachment support

Attach any number of file documents to a generated message.

Each attachment's MIME type is detected from its file name.


Stored, reusable configuration

Microsoft Graph credentials (Tenant ID, Client ID, Client

Secret) are held in an EmailConfiguration entity and managed from a page in the

running app. The client secret is encrypted at rest using the Encryption

module.


Ready-made pages

Ships with overview and new/edit pages for messages and

attachments, a configuration page, and a test page for the Graph API route.


Dependencies


- Mendix Studio Pro 10.24.17 or higher.

- Encryption — required. Used to encrypt and decrypt the

stored Microsoft Graph client secret.

- Community Commons — required. Used for file handling when

writing the EML content.


Import both modules before importing EML File Generation,

otherwise it will show unresolved references.


For the Microsoft Graph route you also need an Entra ID

(Azure AD) app registration with permission to read mail. See the Graph mail

permissions reference

(https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions).


As of version 4.0.0 no additional jar is needed in userlib —

the module now relies only on the JDK for MIME type detection.


Installation


1. Import Encryption and Community Commons from the

Marketplace into your app first.

2. In Studio Pro, go to Marketplace > Import module

package, or use App > Import module package with the downloaded file.

3. Select EML File Generation and import it into your app.

4. The module is added as EMLFileGeneration.

5. Run App > Synchronize app directory and deploy once so

the Java action is compiled.


Configuration


Security


Assign the module roles Admin and User to the appropriate

user roles in your app's security settings. Also configure the Encryption

module's encryption key constant, since the client secret cannot be stored or

read without it.


Generate EML using the Java action


1. Add the Email_Overview page to your navigation.

2. Create a message and fill in From, To, CC, BCC, Subject,

HTML Body, Date Sent, and EML File Name, adding attachments if needed, then

save it.

3. Click Generate EML File on the Email_Overview page to

produce the file.


Generate EML using the Microsoft Graph API


1. Register an application in Entra ID and grant it

permission to read mail, following the Graph mail permissions reference

(https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions).

2. Add the EmailConfiguration_NewEdit page to your

navigation and enter the Tenant ID, Client ID, and Client Secret.

3. Add the EmailToTestGraphAPI page to your navigation.

4. Supply the email address and the message ID, then click

Get EML file. The EML file is generated and downloaded.


Known bugs

None.


Frequently Asked Questions


Do I need Microsoft Graph to use this module?

No. The Java action route builds an EML file entirely from data in your app and needs no external service. Microsoft Graph is only for retrieving the original MIME of an existing mailbox message.


Do I have to install Encryption and Community Commons?

Yes, both are required. The module will not import cleanly without them.


Do I need to add a jar to userlib?

Not since version 4.0.0. Earlier versions needed a javax.activation jar to compile; the module now uses the JDK's own MIME type detection.


What opens an .eml file?

Outlook, Thunderbird, Apple Mail, and most other desktop mail clients open EML natively, since it is the standard MIME message format.


Does generating an EML file send the email?

No. The module produces a file. Sending it is up to you or the end user's mail client.


Where is the Microsoft Graph client secret stored?

In the EmailConfiguration entity, encrypted with the Encryption module. Configure the Encryption module's key before entering credentials.


How is an attachment's content type determined?

From the attachment's file name, using the JDK's built-in lookup. Files with an unrecognised or missing extension fall back to application/octet-stream.

Releases

Version: 4.0.0
Framework Version: 10.24.17
Release Notes:

**EML File Generation**


This module helps to generate EML file using

• Microsoft Graph API

• Custom Java Action


**What's new in V4.0.0**


1. Converted to Mendix Studio Pro 10.24.17.

2. Fixed a compilation failure on Mendix 10. The module used `javax.activation.MimetypesFileTypeMap` to determine an attachment's MIME type, and that package was removed from the JDK in Java 11, so the Java action would not compile. It now uses the JDK's own `URLConnection.guessContentTypeFromName`, falling back to `application/octet-stream`. No extra jar is required in `userlib` any more.

3. Migrated the pages to the React client: the two deprecated data grids are now Data Grid 2, and the reference selector is now a Combo Box.

4. The module package now bundles the pluggable widgets its pages use, so it imports cleanly into apps that do not already have them.


**Generate EML using Graph API:**


Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message)


**Permission to get mime message:**


[https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions)


• Add the Configuration page 'EmailConfiguration_NewEdit' to Navigation to configure the Tenant ID, Client Id, and Client Secret.

• Add the 'EmailToTestGraphAPI' to generate the EML file by passing the Email Message ID and Email. The 'Get EML file' button will generate the EML file, and the file will be downloaded.


**Generate EML using Java Action:**


JA_GenerateEMLFile java action is used to generate the EML file.


• Add the 'Email_Overview' page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it.

• Click on the 'Generate EML File' button in 'Email_Overview' page to generate the EML file.


**Dependencies**

• Mendix Studio Pro 10.24.17 or newer.

• Encryption module

• Community Commons module


**Issues, Suggestions & Feature Requests**

https://github.com/bharathidas/EMLFileGeneration/issues

Version: 3.0.0
Framework Version: 9.24.18
Release Notes: **EML File Generation** This module helps to generate EML file using • Microsoft Graph API • Custom Java Action **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message)](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file. • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the EML file. **Dependencies** • Mendix modeler 9.24.18. • Encryption module • Community Commons Module **Configuration** **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the Check the Example folders for more details. **Screenshots:** ![Screenshot_1](https://user-images.githubusercontent.com/23263603/204250515-93393a05-e839-471c-b647-b666fa8c9a5f.png) ![ConfigurationDetails](https://user-images.githubusercontent.com/23263603/204250534-a9a743c6-f29e-4d4e-ba1f-30dfb1721376.png) ![MicrosoftGraphAPI_TestMicroflow](https://user-images.githubusercontent.com/23263603/204250555-aabf668a-f460-4884-ba5a-20a97f1b04a3.png) ![JavaAction_EML_FileGeneration](https://user-images.githubusercontent.com/23263603/204250575-1fb3f645-43b7-4eae-a00b-9f5668c1d0ed.png)
Version: 2.0.0
Framework Version: 9.12.4
Release Notes: **EML File Generation** This module helps to generate EML file using • Microsoft Graph API • Custom Java Action **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message)](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file. • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the EML file. **Dependencies** • Mendix modeler 9.12.4. • Jars are added as part of the module. • Encryption module • Community Commons Module **Configuration** **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the Check the Example folders for more details. **Known bugs** None ![Screenshot_1](https://user-images.githubusercontent.com/23263603/204250515-93393a05-e839-471c-b647-b666fa8c9a5f.png) ![ConfigurationDetails](https://user-images.githubusercontent.com/23263603/204250534-a9a743c6-f29e-4d4e-ba1f-30dfb1721376.png) ![MicrosoftGraphAPI_TestMicroflow](https://user-images.githubusercontent.com/23263603/204250555-aabf668a-f460-4884-ba5a-20a97f1b04a3.png) ![JavaAction_EML_FileGeneration](https://user-images.githubusercontent.com/23263603/204250575-1fb3f645-43b7-4eae-a00b-9f5668c1d0ed.png)
Version: 1.1.0
Framework Version: 9.12.4
Release Notes: **EML File Generation** This module helps to generate EML file using • Microsoft Graph API • Custom Java Action **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message)](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file. • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the EML file. **Dependencies** • Mendix modeler 9.12.4. • Jars are added as part of the module. • Encryption module • Community Commons Module **Configuration** **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) • Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. • Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file • Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. • Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the Check the Example folders for more details. **Known bugs** None ![Screenshot_1](https://user-images.githubusercontent.com/23263603/204250515-93393a05-e839-471c-b647-b666fa8c9a5f.png) ![ConfigurationDetails](https://user-images.githubusercontent.com/23263603/204250534-a9a743c6-f29e-4d4e-ba1f-30dfb1721376.png) ![MicrosoftGraphAPI_TestMicroflow](https://user-images.githubusercontent.com/23263603/204250555-aabf668a-f460-4884-ba5a-20a97f1b04a3.png) ![JavaAction_EML_FileGeneration](https://user-images.githubusercontent.com/23263603/204250575-1fb3f645-43b7-4eae-a00b-9f5668c1d0ed.png)
Version: 1.0.0
Framework Version: 9.12.4
Release Notes: **EML File Generation** This module helps to generate EML file using • Microsoft Graph API • Custom Java Action **Generate EML using Graph API:** Check the [https://learn.microsoft.com/en-us/graph/outlook-get-mime-message](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message) Permission to get mime message: [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the EML file. **Dependencies** • Mendix modeler 9.12.4. • Jars are added as part of the module. • Encryption module • Community Commons Module **Configuration** **Generate EML using Graph API:** Check the https://learn.microsoft.com/en-us/graph/outlook-get-mime-message **Permission to get mime message:** [https://learn.microsoft.com/en-us/graph/permissions-reference#mail-permissions](https://learn.microsoft.com/en-us/graph/permissions-reference%23mail-permissions) Add the Configuration page ‘EmailConfiguration_NewEdit’ to Navigation to configure the Tenant ID, Client Id, and Client Secret. Add the ‘EmailToTestGraphAPI’ to generate the EML file by passing the Email Message ID and Email. The ‘Get EML file’ button will generate the EML file, and the file will be downloaded. **Generate EML using Java Action:** JA_GenerateEMLFile java action is used to generate the EML file Add the ‘Email_Overview’ page in Navigation and enter the From,To,CC,BCC,Subject,HTMLBody,DateSent,EMLFileName and the attachments if any and Save it. Click on the ‘Generate EML File’ button in ‘Email_Overview’ page to generate the Check the Example folders for more details **Known bugs** None