render.mergeEmail(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Creates a render.EmailMergeResult object for a mail merge with an existing scriptable email template.

Note:

You must load the N/email Module to send and attach the email template to a record.

Returns

render.EmailMergeResult

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/render Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.templateId

number

required

Internal ID of the template.

options.entity

RecordRef

optional

The entity.

options.recipient

RecordRef

optional, the recipient can be specified with this parameter or with the email.send(options) method.

The recipient.

options.customRecord

RecordRef

optional

The custom record.

options.supportCaseId

number

optional

The support case ID.

options.transactionId

number

optional

The transaction ID.

RecordRef

You can use a RecordRef to designate the record to perform the mail merge on.

Note:

The RecordRef object encapsulates the type and ID of a particular record instance.

Property

Type

Required / Optional

Description

RecordRef.id

number

required

Internal ID of the record instance.

RecordRef.type

string

required

The record type ID.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/render Module Script Samples.

The following script sample uses the render.mergeEmail(options) method to attach a record and the email.send(options) method to send the email template to the recipient.

          //Add additional code
...
/**
* @NApiVersion 2.x
*/
require(['N/email', 'N/render'], function(email, render) {
    function sendEmail() {
        var senderId = -5;
        var recipientId = 1711;
        var mergeResult = render.mergeEmail({
            templateId: 7,
            entity: {
                type: 'employee',
                id: senderId
            },
            recipient: {
                type: 'customer',
                id: recipientId
            }
        });
    
        email.send({
            author: senderId,
            recipients: recipientId,
            subject: mergeResult.subject,
            body: mergeResult.body
        });
    }
    sendEmail();
});
...
//Add additional code 

        

Related Topics

N/render Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices