EmailTemplate

You can use this function for OptivaWorkflows and Functions.

Purpose

This function generates a formatted email message using a predefined email template and a set of dynamic parameters, useful for sending consistent, customizable notifications in workflows or scripts.

Syntax

EmailTemplate(template , ParamArray args())

Return Value

If the code is successful, the script displays a new object EmailTemplateText.

Arguments

Argument Description
Template The argument specifies the email template, created and managed by the system administrator via the Email Template form, and supports both plain text and HTML formats.
ParamArray The dynamic parameters are passed to the template to replace placeholders within it. Each parameter corresponds to a placeholder identified by an index, such as [%1], [%2], and so on and the function substitutes these placeholders with the actual values provided in args.

Description

The EmailTemplateText object has the Subject, Message and IsHtml properties filled in with the fully updated and token replacements of the requested template. This is equivalent to calling the Optiva Notify method in regards to filling out of the email template. This allows the script to then use the SendMail method instead where you can pass the Subject, Message and IsHtml arguments from the EmailTemplateText object. Previously, SendMail did not allow for email templates like Notify does, and Notify did not allow for file attachments. Using the EmailTemplate method allows for email templates and file attachments.

You can use the class EmailTemplateText with the following properties:
Public Property IsHtml As Boolean
Public Property Message As String
Public Property Subject As String
To use the EmailTemplateText class in your script, add the following to the list of Imports at the top of the script:
Imports Formation.Shared.Defs

EmailTemplate example

Template code -> Formula [%n] is ready for review by [%n].
	Function Call -> 
	EmailTemplateText msg;
	msg = EmailTemplate("NOTIFY_FORMULA_READY", "F12345", "QA Team");

Result: The formula F12345 is ready for review by QA Team.