This workshop demonstrates how emails can be read from an inbox and processed
via IMAP. This is done by creating a process with an IMAP event source
an IMAP event handler. The email is written to a data group via a Groovy
Please note that emails in HTML can lead to security flaws
2. Example application
Download the example application here.
Import the downloaded file "advanced-techniques-mail-connection-with-imap.zip"
and select the application and process it contains. Then switch to the
open the process "Advanced Techniques - Mail connection with IMAP"
and activate it.
The following functionalities are covered by the application:
Identify the sender
Identify the recipient (including CC)
Identify the arrival time
Identify the subject
Convert email's content from HTML to plaint text
Convert email's content from plaint text to HTML
Present the email in HTML
Present the email in plaint text
Identify / Separate inline attachments
Add the email to an Intrexx data group
Add the attachments to an Intrexx data group
The email's format (HTML / Plain text) can be modified on the
"Settings" page in the application.
First of all, the code imports the class, creates a new instance and
parses the email.
The "pm" object provides us with a variety of methods to, for example,
identify the mail's subject, content (as HTML or plain text), sender or attachments.
def strFrom = pm.sender.address //Identify sender
def strTo = TextUtil.listToString(pm.recipients*.address) //Identify recipient(s)
def strCC = TextUtil.listToString(pm.recipientsCc*.address) //Identify recipient(s) in CC
def attachments = pm.getAttachments() //Identify attachments
def strHTMLContent = pm.getRawHTMLContent() //Ermitteln des Inhalts als HTML
def strPlainTextContent = pm.getPlainTextContent() //Ermitteln des Inhalts als Plain Text
Subsequently, we can add the information and attachments from the email to
Intrexx data groups using INSERT statements.