如何使用套件脚本发送带有信函模板的电子邮件

时间:2017-11-21 12:22:37

标签: netsuite

我正在尝试使用suitescript2发送电子邮件我正在尝试附加字母模板programaticaly。有没有办法附上我的自定义信函模板?

   function templatemerge() {
     var myMergeResult = render.mergeEmail({
templateId: 12,
entity: {
    type: 'customer',
    id: 31921
    },
recipient: {
    type: 'customer',
    id: 31921
    },
supportCaseId: 'NULL',
transactionId: 'NULL',
customRecord: 'custrecordid'
});
    }
    templatemerge();



    function sendEmailWithAttachement() {
    var newId =  context.newRecord;
        var emailbody = 'attachment';
        var senderId = -5;
        var recipientEmail = 'red@imi.com';

        email.send({
           author: senderId,
            recipients: recipientEmail,
            subject: 'Item Fulfillments',
            body: emailbody
        });
    }
    sendEmailWithAttachement();

1 个答案:

答案 0 :(得分:0)

如果,通过信函模板,您的意思是电子邮件模板。这是一个基本的想法(我从一个我正在使用的更大的脚本文件中提取该部分)如何做到这一点。

var emailTemp4=nlapiLoadRecord('emailtemplate',emailTempID4); 
var emailSubj4=emailTemp4.getFieldValue('subject');
var emailBody4=emailTemp4.getFieldValue('content');
var renderer4=nlapiCreateTemplateRenderer();
renderer4.setTemplate(emailSubj4);
renderSubj4=renderer4.renderToString();
renderer4.setTemplate(emailBody4);
renderBody4=renderer4.renderToString();

nlapiSendEmail(-4,'RecipientEmail@domain.com',renderSubj4,renderBody4,null,null);