ftos.messaging.send
Starting with v24.3.0, this is renamed from sendMail to ftos.messaging.send.
Sends an email using a predefined template. It uses the MessageQueue entity to store the email body.
Emails are sent:
-
using the optional
providerNameparameter (starting with v24.3) -
if
providerNameis not specified, asynchronously using job servers afterEmailChannelProviderNameis enabled in the Configuration Manager (starting with 22.9.1) -
a valid SMTP server configured in the web service (for v22.1.8 and prior).
-
using the
channelProviderNameparameter (starting with v24.3.2) through SMTP. Make sure you do the configurations described in the Configuration Manager page.
This is suitable for business logic modules of business service components.
Syntax
For v24.3.1 and before:
function ftos.messaging.send(templateName: string, to: string[], tokens: any, attachments: any, cc: string[], string providerName): void
function ftos.messaging.send(templateName: string, to: any, tokens: any, attachments: any, cc: any, channelProviderName:string): void
| Parameter | Description |
|---|---|
templateName
|
Name of a predefined email template to be used. |
to
|
Recipient's email address. |
tokens
|
Keys for substitution. They are defined as properties of an object and replaced with their values. Tokens are enclosed in brackets in the email template body (e.g., {accountName}). |
attachments
|
The files to be attached to the email. This is a JSON object with its key-value pairs representing:
|
cc
|
Array of strings containing the Carbon Copy email recipients. |
providerName
|
Available with v24.3.1. If this parameter is not passed or is null/empty, then the provider specified in Configuration Manager key EmailChannelProviderName is used. |
|
|
Available starting with v24.3.2. If this parameter is not passed or is null/empty, then the provider specified in Configuration Manager key EmailChannelProviderName is used. |
Examples
In this example:
- We send an email message based on the welcomeTemplate.
- The recipients of the message are john.doe@gmail.com and jane.doe@gmail.com.
- A copy of the message is sent to marketing@mycompany.com.
ftos.messaging.send('welcomeTemplate', ['john.doe@gmail.com', 'jane.doe@gmail.com'], {}, {}, ['marketing@mycompany.com']);
In this example:
- We send a customized offer based on the offerTemplate.
- The recipient of the message is john.doe@gmail.com.
- The accountName token from the message template is replaced with the customer's name (John).
- The termsAndConditions_ddde85d9-ca38-42b8-b6b9-e5cc6bb4078c.pdf file is attached to the email under the TermsAndConditions.pdf name.
ftos.messaging.send('offerTemplate', ['john.doe@gmail.com'], {accountName: 'John'}, {'TermsAndConditions.pdf': 'termsAndConditions_ddde85d9-ca38-42b8-b6b9-e5cc6bb4078c.pdf'},[]);