ftos.messaging.sendNoEx
IMPORTANT!
Starting with v24.3.0, this is renamed from sendMailNoEx to ftos.messaging.sendNoEx.
Starting with v24.3.0, this is renamed from sendMailNoEx to ftos.messaging.sendNoEx.
Sends an email using a predefined template.
IMPORTANT!
Starting with v22.1.9, the email queue is managed by job servers.
For v22.1.8 and prior, in case of errors (email address or SMTP), does not raise an exception, it continues the workflow execution.
Starting with v22.1.9, the email queue is managed by job servers.
For v22.1.8 and prior, in case of errors (email address or SMTP), does not raise an exception, it continues the workflow execution.
This is suitable for business logic modules of business service components.
Syntax
For v22.1.9 and above:
Copy
function ftos.messaging.sendNoEx(templateName: string, to: string[], tokens: any, attachments: any, cc: string[], string providerName): boolean
For v22.1.8 and prior:
Copy
function ftos.messaging.sendNoEx(templateName: string, to: string[], tokens: any, sendAsync: boolean, attachments: any, useDefaultSender: boolean, cc: string[], from: string): boolean
| 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}). |
sendAsync(for v22.1.8 and prior)
|
|
attachments
|
The files to be attached to the email. This is a JSON object with its key-value pairs representing:
|
useDefaultSender(for v22.1.8 and prior)
|
|
cc
|
Array of strings containing the Carbon Copy email recipients. |
from(for v22.1.8 and prior)
|
Specific sender email address which will override the default sender or the current user's account email address (see useDefaultSender). |
providerName (for v24.3) |
If this parameter is not passed or is null/empty, then the provider specified in Configuration Manager key EmailChannelProviderName is used. |
Return Value
- true – The message was sent successfully.
- false – The message was not sent successfully.
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.
Copy
ftos.messaging.sendNoEx('welcomeTemplate', ['john.doe@gmail.com', 'jane.doe@gmail.com'], {}, {}, null);
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.
- Display a Success or Failure notification depending on the result. For details on how to display notifications, see ftos.context.response.setMessage.
Copy
if(ftos.messaging.sendNoEx('offerTemplate', ['john.doe@gmail.com'], {accountName: 'John'}, {'TermsAndConditions.pdf': 'termsAndConditions_ddde85d9-ca38-42b8-b6b9-e5cc6bb4078c.pdf'}, [], )) {
ftos.context.response.setMessage('Success');
} else {
ftos.context.response.setMessage('Failure');
};