Send Email using Email Template

To create an email template record:

Go to Documents > Templates > Email Templates > New.

In suitescript file add code:

var emailMerger = nlapiCreateEmailMerger(445);
//445 Email template id
// emailMerger.setEntity(customer, 865);
// emailMerger.setRecipient(customer, customrecord_jj_cust_notificationSearch[0].id);
// emailMerger.setSupportCase(customrecord_jj_cust_notificationSearch[0].id);
// emailMerger.setTransaction(customrecord_jj_cust_notificationSearch[0].id);
//var emailSubject = mergeResult.getSubject();
emailMerger.setCustomRecord('customrecord_jj_cust_notification', recordid);
var mergeResult = emailMerger.merge();
var emailSubject = mergeResult.getSubject();
var emailBody = mergeResult.getBody();
var records = new Object();
//865 custom recordtype internalId or scriptId
records['recordtype'] = 865;  
//2444 sender.internalId of an employee record 
nlapiSendEmail(2444, email, emailSubject, emailBody, email, email, records, null, true, false, null)

Leave a comment

Your email address will not be published. Required fields are marked *