Skip to main content

Mail Processing

Auto-generated

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:

  1. Check whether the email has already been imported using its Message-ID.
  2. Resolve sender and recipients.
  3. Match sender and recipients to existing contacts.
  4. Determine the responsible employee.
  5. Create a new Activity.
  6. Store the original email (Mail.eml).
  7. Store all relevant attachments.
  8. 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 FieldSource
CategoryMail
DirectionDetermined based on whether the internal user is sender or recipient (Incoming / Outgoing)
SubjectEmail subject (max. 254 characters)
Entry DateEmail sent date
ResponsibleDetermined from the involved internal users
ContentHTML representation of the email including sender, recipients, CC, sent date, subject, attachment overview and sanitized email body
Linked ContactsMatching contacts and organizations found for sender and recipients
DocumentsOriginal 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 TypeContainer NameKeyword
Mail.emlDOCUMENTMAINDOCUMENT

Regular Attachments

All standard file attachments (e.g. PDF, DOCX, XLSX, ZIP, images) are stored as regular documents.

Attachment TypeContainer NameKeyword
Standard attachmentsDOCUMENTMAINDOCUMENT

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 TypeContainer NameKeyword
Inline attachmentsEMAIL_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 TypeContainer NameVisible in Document List
Original email (Mail.eml)DOCUMENTYes
PDF, Office documents, ZIP files, images, etc.DOCUMENTYes
Inline attachments (cid:)EMAIL_INLINE_ATTACHMENTNo
Attachments with x-adito-nodata=trueNot storedNo

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 DOCUMENT container.
  • Stores inline attachments with the EMAIL_INLINE_ATTACHMENT container.
  • Replaces HTML cid: references with links to the stored binary resources.
  • Executes all registered email processors after the import has completed.