# SendMailAction

With the SendMailAction the system can send mails when something triggers a workflow.

# Configuration:

In the *.xml file you have to configure the trigger field, the action class, and the toMail or the toUser parameter. You can also configure some recommended parameters and custom parameters.

<workflow_event>
 <conditions/>
  <trigger_fields>
    <trigger_field>trigger-field</trigger_field>
  </trigger_fields>
  <actions>
    <action class="com.cm4ap.ce.workflow.action.SendMailAction">
      <parameters>
        <entry key="toMail">test@4allportal.com</entry>
        </parameters>
    </action>
  </actions>
</workflow_event>

# Parameters:

Parameters are given as follows:

<entry key="parameterKey">parameterValue</entry>
//example:
<entry key="language">en_US</entry>

Possible configurable parameters:


# NOTE Minimum one recipient is required.

Parameter Definition Notes
toMail Defines the recipient of a mail
by E-Mail.
------------------ ------------------------------------- ---------------------------------------------
toUser Defines the recipient of a mail You can use fields of the current bean to
by UserId or fields. get an user id. eg: {created_by}
Separate inputs by comma.
------------------ ------------------------------------- ---------------------------------------------
toRoleName Defines a whole role as recipients Format:
of a mail by role name. String Array
------------------ ------------------------------------- ---------------------------------------------
toRoleId Defines a whole role as recipients Format:
of a mail by role id. String Array
------------------ ------------------------------------- ---------------------------------------------
template Defines the template which should Default:
be used. :ref:Learn how templates The recipients will receive a notification
work email that no template is specified
------------------ ------------------------------------- ---------------------------------------------
subject Defines the subject of the mail. Default:
Only use if no subject is defined The default subject for the mail is
in the html template “4ALLPORTAL systemmail”
------------------ ------------------------------------- ---------------------------------------------
bccMail Defines the blind carbon copy by
user mail-address
------------------ ------------------------------------- ---------------------------------------------
ccMail Defines the carbon copy by user
mail-address
------------------ ------------------------------------- ---------------------------------------------
bccUser Defines the blind carbon copy You can use fields of the current bean to
recipient of a mail by UserId or get an user id. eg: {created_by}
fields. Separate inputs by comma.
------------------ ------------------------------------- ---------------------------------------------
ccUser Defines the carbon copy recipient You can use fields of the current bean to
of a mail by UserId or fields. get an user id. eg: {created_by}
Separate inputs by comma.
------------------ ------------------------------------- ---------------------------------------------
bccRoleName Defines the blind carbon copy by Format:
role name String Array
------------------ ------------------------------------- ---------------------------------------------
bccRoleId Defines the blind carbon copy by Format:
role id String Array
------------------ ------------------------------------- ---------------------------------------------
ccRoleName Defines the carbon copy by user Format:
role name String Array
------------------ ------------------------------------- ---------------------------------------------
ccRoleId Defines the blind carbon copy by Format:
role id String Array
------------------ ------------------------------------- ---------------------------------------------
language Defines the language to process The default language of the mail is the
the associated template language of the running system
------------------ ------------------------------------- ---------------------------------------------
userId Defines the sender of the mail Default: 4ap_su
  • You can add custom parameters and use them as variable in the mail template.

# Template variables:

Available variables for the mail template and subject:

Variable Description
external_url ROOT-URL of the running system exp.: 4allportal.net
modByUser.mod_time Field modification time
modByUser.id Id from user who modified the field
modByUser.module_name Name of the module the modded field was located
modByUser.type Type of user who modified the field
modByUser.username Username of user who modified the field
object.mod_time Bean modification time
object.id Id of bean which was modified
object.module_name Module name of module the modified bean was located
object.type Type of bean which was modified
custom.* All parameters which are configured in the workflow xml

# NOTE You can use all fields of the current bean in the mail template. The bean is saved in the object variable.

# Code example

<?xml version="1.0" encoding="UTF-8"?>
<workflow_event>

  <description>Some description</description>
  <conditions/>
  <trigger_fields>
    <trigger_field>test_myfield</trigger_field>
  </trigger_fields>
  <actions>
    <action class="com.cm4ap.ce.workflow.action.SendMailAction">
      <parameters>
        <entry key="template">testEmail</entry>
        <entry key="toRoleName" class="string[]">
              <value>Admin</value>
              <value>User</value>
        </entry>
        <entry key="toMail">test@4allportal.com</entry>
        <entry key="subject">Test mail</entry>
        <entry key="language">en_US</entry>
        <entry key="userId">148a62e9-cb1d-454f-9a7d-52fd6ec0bd35</entry>
        <!-- custom parameters -->
        <entry key="test">test</entry>
      </parameters>
    </action>
  </actions>
</workflow_event>

# Images in HTML template

In your HTML template you can use CID images like this:

<body>
 {objectimage source=object.id type="medium" module="file" mode="letterbox" width="150" height="150"}
</body>

The object.id is the id of the current changed asset.

Request missing documentation