Chapter 32. Email Task
The Email task sends an email based on the task properties.
Registering Email Task in Business Central
Email task is not registered by default in Business Central, and therefore must be registered by the user.
Follow the procedure below to configure Business Central to use Email service task.
- Design a BPMN2 process definition in the Process Designer of Business Central. Add the Email task to the workflow.
- Select the Email task and click to open the Properties panel.
Open Assignments and fill in the
To
,From
,Subject
, andBody
properties, and any other relevant input attributes.Alternatively, values can be mapped to properties using Process Variable to Task Variable mapping assignments.
From the Process Designer, open the Properties panel and select the
Variable Definitions
property to map variables.
Registering EmailWorkItemHandler
EmailWorkItemHandler
is the work item handler implementation of the Email Service task. The Email work item is included in the work item definition file by default, however EmailWorkItemHandler
is not a part of the default kie-deployment-descriptor.xml
file, and therefore must be explicitly registered by the user.
To register EmailWorkItemHandler
:
-
Open the Project Editor and click Project Settings: Project General Settings
Deployment descriptor from the menu. Scroll down to the Work Item handlers list and click Add to add the
EmailWorkItemHandler
to the list. For example:new org.jbpm.process.workitem.email.EmailWorkItemHandler("localhost","25","me@localhost","password");
Alternatively, email server parameters can be supplied using a constructor in the
ProcessMain.java
file:EmailWorkItemHandler emailWorkItemHandler = new EmailWorkItemHandler("localhost", "1125", "", "",true); ksession.getWorkItemManager().registerWorkItemHandler("Email", emailWorkItemHandler );
Configuring Deadline
You can configure the Deadline email feature in two ways:
Mail Session on Container Level
With this method, the Deadline email feature uses
EmailSessionProducer
to look up themail/jbpmMailSession
using JNDI. The following example is for Red Hat JBoss EAPstandalone.xml
:<system-properties> ... <property name="org.kie.mail.session" value="java:jboss/mail/mail/jbpmMailSession"/> ... </system-properties> ... <subsystem xmlns="urn:jboss:domain:mail:1.2"> <mail-session name="default" jndi-name="mail/jbpmMailSession" > <smtp-server outbound-socket-binding-ref="mail-smtp" tls="true"> <login name="email@gmail.com" password="___"/> </smtp-server> </mail-session> </subsystem> ... <outbound-socket-binding name="mail-smtp"> <remote-destination host="smtp.gmail.com" port="587"/> </outbound-socket-binding>
Using email.properties
If the
mail/jbpmMailSession
is not found, Red Hat JBoss BPM Suite searches for/email.properties
on the class path with content similar to the following:mail.smtp.host=localhost mail.smtp.port=25 mail.from=xxx@xxx.com mail.replyto=xxx@xxx.com
Input Attributes
The following parameters are required by default:
- To
-
The email address of the email recipient. Separate multiple addresses by a semicolon (
;
). - From
- The email address of the sender of the email.
- Subject
- The subject of the email.
- Body
- The HTML body of the email.
The following parameters are optional, and can be configured by mapping values assigned to these properties using Process Variable to Task Variable
mapping in Assignments:
- Reply-To
-
Sets the reply recipient address to the
From
address of the received message. Separate multiple addresses by a semicolon (;
). - Cc
-
The email address of the carbon copy recipient. Separate multiple addresses by a semicolon (
;
). - Bcc
-
The email address of the blind carbon copy recipient. Separate multiple addresses by a semicolon (
;
). - Attachments
-
The URL of the files you want to attach to the email. Multiple attachments can be added to the email using a comma (
,
) to separate each URL in the list. - Debug
A boolean value related to the execution of the Email work item. For example:
"Success" = true
The Email task is completed immediately and cannot be aborted.