Skip to main content
Version: 1.24.2

SimpleEmailOutbound

This server-side class provides methods for interaction with the email objects in email notification scripts. In addition to these methods, use the email global object available in the notification scripts.

addAddress(address, displayName)


Use this method to populate the To field of the Email (sys_email) table record with the address specified.

Parameter(s):

NameTypeMandatoryDefault value
addressStringYN
displayNameStringNnull

Return:

TypeDescription
VoidThis method does not return a value.

Example:

addAddress()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.addAddress(current.caller.email, current.caller.display_name);
})(current, template, email, event);

addAddressBcc(address, displayName)


Use this method to populate the Blind carbon copy (BCC) field of the Email (sys_email) table record with the address specified.

Parameter(s):

NameTypeMandatoryDefault value
addressStringYN
displayNameStringNnull

Return:

TypeDescription
VoidThis method does not return a value.

Example:

addAddressBcc()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
if (+event.param_2 > 1000) {
email.addAddressBcc(
current.assigned_user.manager.email,
current.assigned_user.manager.display_name
);
}
})(current, template, email, event);

addAddressCc(address, displayName)


Use this method to populate the Carbon copy (CC) field of the Email (sys_email) table record with the address specified.

Parameter(s):

NameTypeMandatoryDefault value
addressStringYN
displayNameStringNnull

Return:

TypeDescription
VoidThis method does not return a value.

Example:

addAddressCc()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.addAddressCc(
current.assigned_user.manager.email,
current.assigned_user.manager.display_name
); })(current, template, email, event);

getAddresses()


Use this method to get the recipient addresses.

Return:

TypeDescription
Array of StringsThis method returns an array of strings that contain the recipient addresses.

Example:

getAddresses()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getAddresses();
})(current, template, email, event);

getAddressesBcc()


Use this method to return a list of recipient addresses stated in the BCC field.

Return:

TypeDescription
Array of StringsThis method returns an array of strings that contain the recipient addresses from the BCC field.

Example:

getAddressesBcc()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getAddressesBcc();
})(current, template, email, event);

getAddressesCc()


Use this method to return the recipients' addresses stated in the CC field.

Return:

TypeDescription
Arrays of StringsThis method returns an array of strings that contain addresses stated in the CC field.

Example:

getAddressesCc()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getAddressesCc();
})(current, template, email, event);

getBody()


Use this method to get the message body.

Return:

TypeDescription
StringThis method returns the message body.

Example:

getBody()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getBody();
})(current, template, email, event);

getFrom()


Use this method to return a sender's address.

Return:

TypeDescription
StringThis method returns the address of a sender.

Example:

getForm()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getFrom();
})(current, template, email, event);

getReplyTo()


Use this method to return the address set in the Reply to field.

Return:

TypeDescription
StringThis method returns an address specified for a reply.

Example:

getReplyTo()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getReplyTo();
})(current, template, email, event);

getSubject()


Use this method to return the subject of a message.

Return:

TypeDescription
StringThis method returns the message subject line.

Example:

getSubject()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.getSubject();
})(current, template, email, event);

setBody(bodyText)


Use this method to set the body of a message in the Body (Plain text) field.

Parameter(s):

NameTypeMandatoryDefault value
bodyTextStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setBody()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.setBody(`Additional comments:
${current.sys_updated_by.display_name}: "${current.additional_comments}"`
);
})(current, template, email, event);

setFrom(address)


Use this method to change the From field value of an outgoing email. By default, the outgoing email From field contains the address taken from the From field of the default email account.

To change the default email account, change the value of the system property default.email.account.send.

The parameter value must match the regular expression specified in the email.validation.reg_exp property.

Regardless of the value in the Form field of an outgoing email, the system conducts the sending authorization with the data set in the default email account.

Parameter(s):

NameTypeMandatoryDefault value
addressStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setFrom()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.setFrom('test@example.com');
})(current, template, email, event);

setReplyTo(address)


Use this method to set the Reply to address. The parameter value must match the regular expression specified in the email.validation.reg_exp property.

Parameter(s):

NameTypeMandatoryDefault value
addressStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setReplyTo()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.setReplyTo('test@example.com');
})(current, template, email, event);

setSubject(subject)


Use this method to set the subject of an email.

Parameter(s):

NameTypeMandatoryDefault value
subjectStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setSubject()
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.setSubject('Additional comments have been added');
})(current, template, email, event);