Sending Emails with JavaScriptJavaScript can be used to send an email at any time in a Workflow, and can be a preferable method of sending automatic emails built from the content of multiple Fields.
How ToInside any JavaScript-manipulating Field (Calculate, JavaScript, JavaScript - Button), use the function specified below.
Simple Syntax
The simple syntax requires a list of parameters:
Script.Email.Send(connectorType, connectorName, subject, recipients, from, body, defer, callback);
Example:
Alternate Syntax
Since many of the arguments for the above syntax are optional, there is an alternate syntax where a JavaScript object is passed instead. This means that only the desired optional parameters need to be passed:
Any optional parameters that are omitted will use their default value, as stated in the above table. As this is a JavaScript object, the order in which the parameters are listed in this alternate syntax doesn't matter, as long as the key:value pairs are preserved.
NotesAs multiple duplicate emails can be queued, it is advised that caution is used if this function is invoked in a Calculate Field, due to the way that Calculate Fields will run every time an action is taken or Field's value is altered.
It is also possible to make use of the Script.Message.Send() function to send both SMS and emails.
|