Scripts of the type Email

Scripts of this type are used to configure the email functionalities of ConSol CM. 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.

Email scripts for incoming emails

Incoming emails are processed using NIMH, see Email configuration. When ConSol CM receives an email, it is processed by several scripts.

Figure 5: Email scripts in ConSol CM

Email scripts for outgoing emails

The processing of outgoing emails can be fine-tuned by queue. Each queue can have an email script which is executed for every email written from a case in this queue. This applies to emails which are sent manually by a user and to automatic emails which use the method Mail.useDefaultScript().

A common use case for outgoing email scripts is to set queue-specific Reply-to or From addresses.

The default configuration includes an example script for outgoing emails:

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

def queueReplyAddress = "serviceteam@mycompany.com"

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

// address using the configurationService!

 

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

Code example 5: Email script

Common email attributes are:

Reply-to addresses in ConSol CM

There are four ways to set the Reply-to address:

  • System property mail.reply.to
    If this system property is set, its value is displayed in the email editor in the Web Client. The email address can be overwritten by the outgoing email script. If the page customization attribute showReplyTo for the type mailTemplate is set to false, the Reply-To address is not displayed in the email editor, but used anyway.
  • Queue-specific outgoing email script
    If a Reply-to address is set in the outgoing email script, this address is used. It overwrites the system property mail.reply.to, although the address set in this property is displayed in the email editor.
  • System property mail.from
    Only relevant if the Reply-to address is neither set in the system property mail.reply.to nor in the outgoing email script. In this case, most email clients use the From address as Reply-to address.
  • Email address of the current user
    Only relevant if the Reply-to address is neither set in the system properties mail.reply.to or mail.from nor in the outgoing email script. In this case, the personal email address of the currently logged in user is used as Reply-to address for emails from the Web Client.

The Reply-to address which was really used is displayed in the case history of the Web Client.

Best practice:

Always set a Reply-to address to prevent personal email addresses from being used, as this would lead to customer emails being sent to the users’ personal email accounts instead of ConSol CM. There are two places to set the Reply-to address:

  • System property mail.reply.to
    This is the simplest way to set the Reply-to address. This address is also displayed in the email editor.
  • Queue-specific outgoing email script
    If different Reply-to addresses are required depending on the queue, we recommend to write an 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 system property and queue-specific Reply-to addresses. In this way the email address set in the outgoing email script is used for queues with such a script, and the email address from the system property is used for the rest of the queues.

Usage in workflow scripts

When sending emails in workflow scripts, you need to set the Reply-to address within the script.

  • Retrieve the value of the system property mail.reply.to and set it as a Reply-to address in the outgoing email:

    configurationService.getValue("cmweb-server-adapter","mail.reply.to")

  • Use the Mail object if the outgoing email script should be used. This overwrites the system property mail.reply.to.

    mail.useDefaultScript()