Sends an email message through Salesforce using the user's Salesforce account. The child commands define mostof the properties of the message, including the message body. As the email is sent through the user'sSalesforce connection, the "From" field of the message is automatically set to the email address set in theuser's Salesforce account, unless the attribute orgWideEmailAddressId
is defined in which case anorganization-wide alias may be used instead.
Child commands
All the child commands set different properties of the generated email message.
to
Required. Up to 100 recipients may be defined through these childcommands, but at least one is required.cc
Optional. Upto 25 "CC" addresses may be specified through these child commands.bcc
Optional.Up to 25 "BCC" addresses may be specified through these child commands.replyTo
Optional. One child command of this kind may be present to set the "Reply-To"header.textBody
Optional. One child command of this kind may be present to set the message'splain text body.htmlBody
Optional. One child command of this kind may be present to set the message'sHTML body.attachment
Optional. Any number of file attachments may be added through these childcommands as long as the total file size doesn't exceed 10 MB.recordAttachment
Optional. Any number of record-based file attachments may be addedthrough these child commands. Any ContentVersion records specified as attachments will also cause theirContentDocuments to be linked to the EmailMessage record generated if therelatedTo
attributeis defined.
Attributes
subject | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines the subject line of the email message. |
senderName | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines the name of the message's sender. Do note that this onlysets the name, not the "From" address. This attribute may not be defined together with the If not defined, the name set in the active user's Salesforce account appears asthe sender. |
orgWideEmailAddressId | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Allows the email message's sender name and email address to beset to an organization-wide alias instead of the currently active user's name and email address. Theexpected value is the ID of an OrgWideEmailAddress record. This attribute may not be definedtogether with the If not defined, the name and email address set in the active user'sSalesforce account appears as the sender information. |
relatedTo | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Allows the sending of the email message to be accompanied by acreation of an EmailMessage record that is linked to the record defined by this attribute. Theresolved value should therefore be the ID of a record. If not defined, no linked EmailMessagerecord is created. |
relatedToWhom | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
If sending the email causes a Task record to be generated, thisattribute defines the WhoId field of that email Task, which links it to a Contact, Lead or User. Theresolved value is therefore expected to be the Id of a Contact, Lead or User record. If not defined, the generated Task will not be related to any Contact or such. |
useSignature | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
Defines if the email-sending Salesforce user's email signature isincluded in the sent message. If not defined, the value of "true" is used, causing thesignature to be included. |
Examples
The mail
command works together with all of its possible child commands in order to produceand send an email message. Note that you can also make use of the basic logic control commands, such as if and forEach, todynamically alter the email properties.
<mail subject="Test mail"><to value="${teamLeader.emailAddress}"><forEach value="${teamMembers}" var="teamMember"><cc value="${teamMember.emailAddress}"><htmlBody value="${composedEmailBody}"><if test="${includeDoc}"><attachment value="${composedDoc}">