Skip to content

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.

xml
<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:

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

Possible configurable parameters:


NOTE Minimum one recipient is required. ​

ParameterDefinitionNotes
toMailDefines the recipient of a mail
by E-Mail.
----------------------------------------------------------------------------------------------------
toUserDefines the recipient of a mailYou can use fields of the current bean to
by UserId or fields.get an user id. eg:
Separate inputs by comma.
----------------------------------------------------------------------------------------------------
toRoleNameDefines a whole role as recipientsFormat:
of a mail by role name.String Array
----------------------------------------------------------------------------------------------------
toRoleIdDefines a whole role as recipientsFormat:
of a mail by role id.String Array
----------------------------------------------------------------------------------------------------
templateDefines the template which shouldDefault:
be used. :ref:Learn how templatesThe recipients will receive a notification
work <templates>email that no template is specified
----------------------------------------------------------------------------------------------------
subjectDefines the subject of the mail.Default:
Only use if no subject is definedThe default subject for the mail is
in the html template“4ALLPORTAL systemmail”
----------------------------------------------------------------------------------------------------
bccMailDefines the blind carbon copy by
user mail-address
----------------------------------------------------------------------------------------------------
ccMailDefines the carbon copy by user
mail-address
----------------------------------------------------------------------------------------------------
bccUserDefines the blind carbon copyYou can use fields of the current bean to
recipient of a mail by UserId orget an user id. eg:
fields.Separate inputs by comma.
----------------------------------------------------------------------------------------------------
ccUserDefines the carbon copy recipientYou can use fields of the current bean to
of a mail by UserId or fields.get an user id. eg:
Separate inputs by comma.
----------------------------------------------------------------------------------------------------
bccRoleNameDefines the blind carbon copy byFormat:
role nameString Array
----------------------------------------------------------------------------------------------------
bccRoleIdDefines the blind carbon copy byFormat:
role idString Array
----------------------------------------------------------------------------------------------------
ccRoleNameDefines the carbon copy by userFormat:
role nameString Array
----------------------------------------------------------------------------------------------------
ccRoleIdDefines the blind carbon copy byFormat:
role idString Array
----------------------------------------------------------------------------------------------------
languageDefines the language to processThe default language of the mail is the
the associated templatelanguage of the running system
----------------------------------------------------------------------------------------------------
userIdDefines the sender of the mailDefault: 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:

VariableDescription
external_urlROOT-URL of the running system exp.: 4allportal.net
modByUser.mod_timeField modification time
modByUser.idId from user who modified the field
modByUser.module_nameName of the module the modded field was located
modByUser.typeType of user who modified the field
modByUser.usernameUsername of user who modified the field
object.mod_timeBean modification time
object.idId of bean which was modified
object.module_nameModule name of module the modified bean was located
object.typeType 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
<?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:

html
<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