Scripts of Type E-Mail

Scripts of this type are used for several features. Some of the scripts are part of the default system configuration and have to be modified according to the customer-specific system configuration. You can also add your own scripts.

IMPORTANT INFORMATION

Since ConSol CM version 6.9.4, there are two modes to receive incoming e-mails:

For all configurations/settings which are valid for both modes, no further notes are added. For all settings which vary depending on the mode, this will be explained in separate (i.e., Mule/ESB- or NIMH-specific) sections.

E-Mail Scripts for the Processing of Incoming E-Mails in Mule/ESB Mail Mode

When an e-mail is received by ConSol CM, it is processed by several scripts, see following figure.

Figure 401: ConSol CM Admin Tool - E-mail scripts (Mule/ESB Mail)

E-Mail Scripts for the Processing of Incoming E-Mails in NIMH Mode

When an e-mail is received by ConSol CM, it is processed by several scripts, see following figure.

Figure 402: ConSol CM Admin Tool - E-mail scripts (NIMH)

Differences between Scripts in Mule/ESB Mail and NIMH

When NIMH is enabled, different Groovy classes have to be used in the e-mail scripts than when using Mule/ESB Mail mode. Please see the mapping in the table below.

Mule

NIMH

where required:

import com.consol.cmas.esb.mail.MailContextService

where required:

import com.consol.cmas.nimh.extension.MailSupportService

import com.consol.cmas.nimh.common.model.MailHolder

mailContextService

mailSupportService

msg

with respective methods, example:

mailLog.info("Routing " + msg.getUniqueId())

mailHolder

with respective methods, example:

mailLog.info("Routing " + mailHolder.getUid()

mailLog

mailLog

spring cm services

spring cm services

all places where mailHolder is used

Example: see Example OLD below

pipeContext (used as parameter in mailSupportService invocations)

Example: see Example NEW below

pipeContext is an object of class MailPipeContext

msg.setProperty(...)

pipeContext.setAttribute(...)

esb endpoints in mail routing script ("target handlers"):

endpoints["esb_mail_mailToClosedTicketEndpoint"]

endpoints["esb_mail_appendToTicketEndpoint"]

endpoints["esb_mail_createTicketEndpoint"]

script endpoints in mail routing script ("target handlers"):

endpoints["mailToClosedTicketScript"]

endpoints["appendToTicketScript"]

endpoints["createTicketScript"]

Example OLD:

String email = mailContextService.extractMailFromField(msg)

Example NEW:

String email = mailSupportService.extractMailFromField(mailHolder, pipeContext)

The steps you have to perform when you want to switch your ConSol CM system from Mule/ESB Mail mode to NIMH mode are described in section Switching from Mule/ESB Mail to NIMH.

E-Mail Scripts for Outgoing E-Mails

For every queue, an E-mail script can be configured. Please see section Queue Administration for an explanation how to configure this. An e-mail which is written from a ticket in this queue (automatically by the workflow or manually by an engineer) passes through this script before it leaves the ConSol CM system. So in this E-mail script you can change or set queue-specific settings for the outgoing e-mail. A common use case is the setting of a queue-specific Reply-To address in order to use team-specific Reply-To addresses.

An example of an outgoing E-mail script is the following script which is part of the ConSol CM default application:

Within the outgoing E-mail script, the Java object mailEntry is implicitly available as the object mail. You have to set all required attributes for the outgoing e-mail using the mail.setAttribute() or mail.setAttributes() methods.

def queueReplyAddress = "serviceteam@mycompany.com"

// you might also use system properties for the queue-specific e-mail addresses and fetch an

// address using the configurationService!

 

mail.setAttribute('Reply-to', queueReplyAddress)

Code example 64: E-mail script

Common e-mail attributes are:

For a very detailed description of the e-mail format, please refer to RFC 5322.

When you work with the configuration of the Reply-To e-mail address, please note the following technical behavior of ConSol CM and adapt your system accordingly!

The technical background:

There are four potential Reply-To addresses which you deal with:

  1. The Reply-To address which is set with the system property mail.reply.to. If it is set, it will be displayed in the Ticket E-Mail Editor in the Web Client. If it is really the effective Reply-To address in an e-mail depends on the configuration in the queue-specific outgoing e-mail script. See next item. If the Page Customization attribute showReplyTo for the type mailTemplate is set to false, no Reply-To address will be displayed in the Ticket-E-Mail-Editor, but if the property mail.reply.to is set, this address will be used anyway - unless an outgoing mail script sets another address, see next item.
  2. The Reply-To address which is set in a queue-specific outgoing e-mail script. Since the outgoing e-mail script is the last instance which processes an outgoing e-mail, the Reply-To address set in this script will always be the effective Reply-To address which is used. In case the mail.reply.to property is set, this mail-reply.to-address will not really be used (but it will be displayed in the Ticket E-Mail Editor which might cause some confusion! What that means for your system configuration is explained in the next section).
  3. The e-mail address which is set in the system property mail.from. If this is set and neither mail.reply.to nor a queue-specific Reply-To address is set, most e-mail clients will set the From address as Reply-To address.
  4. The e-mail address of the current engineer (the engineer who is logged in to the Web Client). This personal e-mail address is used as Reply-To address for e-mails from the Web Client if neither the mail.reply.to property is set nor a queue-specific outgoing e-mail script is configured nor the mail.from property is set.

In the Web Client, in the ticket history, the Reply-To address which was really used is always displayed for outgoing e-mails. So even in case there should be a difference between the address which was displayed in the Ticket E-Mail Editor (the mail.reply.to property) and the Reply-To address which was really used (the Reply-To in the queue-specific outgoing e-mail script), the effective address is displayed. This would be the one from the script in this case.

What we recommend:

A system Reply-To address should always be set! You can decide if you

or

However, since the e-mail communication should take place via ConSol CM and not using personal e-mail addresses, one of the two system settings mentioned above should be used to prevent CM from using personal e-mail addresses as Reply-To. The latter would automatically lead to customer e-mails being sent to an engineer's personal e-mail account instead of CM.

What that means for your system configuration:

  1. The simplest way to set a Reply-To address is by using the mail.reply.to system property. It will be displayed in the Ticket E-Mail Editor and will be the effective Reply-To address.
  2. If queue-specific Reply-To addresses are required, we recommend to write one outgoing mail script where queue names are mapped to specific Reply-To addresses. This can then be extended for Bcc, Cc or other addresses.
    You can combine the mail.reply.to property and queue-specific Reply-To addresses: for all queues without a specific outgoing mail script, the mail.reply.to address will be used, for all queues which have a queue-specific outgoing mail script that contains a Reply-To address, this will be used.

What that means when you work with workflow scripts which send e-mails:

(A detailed explanation is provided in the ConSol CM Process Designer Manual!)

If neither the system property nor the queue-specific outgoing e-mail script is used, i.e. when the Reply-To address is not set, usually the From address will be used as Reply-To by the e-mail client.