Mail Processing
This page is imported automatically from an external repository.
Source project: Open repository
Overview
Incoming emails are processed by the IncomingEmailExecutor, which is invoked by the Mailbridge or the UniversalFileProcessor(Import Mail dashlet). During processing, the email is assigned to an Activity, the original email is archived, and all relevant attachments are stored.
Prerequisites
In order for the Mailbridge to work, you need to configure it accordingly before Configuration of the Mailbridge
Automatic Processing
After creating an instance of the incomingMailExecter
const incomingMailExec = new IncomingEmailExecutor(mailObj);
The import process is started by calling:
incomingMailExec.autoProcess();
During processing, the following steps are executed:
- Check whether the email has already been imported using its Message-ID.
- Resolve sender and recipients.
- Match sender and recipients to existing contacts.
- Determine the responsible employee.
- Create a new Activity.
- Store the original email (
Mail.eml). - Store all relevant attachments.
- Execute all registered email processors.
Created Activity
For every successfully processed email, a new Activity of category Mail is created (unless an activity for the same Message-ID already exists).
The activity is populated with the following information:
| Activity Field | Source |
|---|---|
| Category | Mail |
| Direction | Determined based on whether the internal user is sender or recipient (Incoming / Outgoing) |
| Subject | Email subject (max. 254 characters) |
| Entry Date | Email sent date |
| Responsible | Determined from the involved internal users |
| Content | HTML representation of the email including sender, recipients, CC, sent date, subject, attachment overview and sanitized email body |
| Linked Contacts | Matching contacts and organizations found for sender and recipients |
| Documents | Original email (Mail.eml) and all regular attachments |
Activity Content
The activity content is generated as HTML and contains:
- Sender
- Recipients (To)
- CC recipients
- Sent date
- Subject
- List of file attachments
- Sanitized HTML email body (or converted plain text if no HTML body exists)
If inline attachments are referenced in the HTML (cid:), these references are automatically replaced with links to the stored binary resources so that embedded images remain visible inside the activity.
Contact Linking
During processing, the sender and all recipients are matched against existing contacts.
Depending on the match, the activity is linked to:
- Persons
- Organizations (automatically linked for person contacts)
- Employees (used to determine the responsible user)
If both active and inactive contacts exist, active contacts are preferred.
Duplicate Detection
Before creating a new activity, the executor checks the email's Message-ID against the MAILDUPLICATE table.
If an activity for the same Message-ID already exists, no new activity is created. Instead, the existing activity is returned to the caller.
Attachment Storage
The saveAttachment() method determines how each attachment is stored.
Original Email
The complete email is always stored as an .eml document.
| Attachment Type | Container Name | Keyword |
|---|---|---|
Mail.eml | DOCUMENT | MAINDOCUMENT |
Regular Attachments
All standard file attachments (e.g. PDF, DOCX, XLSX, ZIP, images) are stored as regular documents.
| Attachment Type | Container Name | Keyword |
|---|---|---|
| Standard attachments | DOCUMENT | MAINDOCUMENT |
These documents are visible in the Activity's document list.
Inline Attachments
Attachments referenced from the HTML body using a cid: reference (typically embedded images such as logos or signatures) are stored separately.
| Attachment Type | Container Name | Keyword |
|---|---|---|
| Inline attachments | EMAIL_INLINE_ATTACHMENT | (none) |
Characteristics:
- Not visible in the document list.
- Used exclusively for rendering the HTML email.
cid:references inside the HTML are automatically replaced with binary URLs.- inline attachments will also be directly shown in the decsription of the created activity
Ignored Attachments
Attachments with the following mail header are ignored completely:
x-adito-nodata = true
These attachments are neither stored nor displayed.
Attachment Summary
| Attachment Type | Container Name | Visible in Document List |
|---|---|---|
Original email (Mail.eml) | DOCUMENT | Yes |
| PDF, Office documents, ZIP files, images, etc. | DOCUMENT | Yes |
Inline attachments (cid:) | EMAIL_INLINE_ATTACHMENT | No |
Attachments with x-adito-nodata=true | Not stored | No |
Summary
The IncomingEmailExecutor performs the complete processing of incoming emails. It:
- Creates an Activity.
- Stores the original email as
Mail.eml. - Stores regular attachments with the
DOCUMENTcontainer. - Stores inline attachments with the
EMAIL_INLINE_ATTACHMENTcontainer. - Replaces HTML
cid:references with links to the stored binary resources. - Executes all registered email processors after the import has completed.