Replace email template value using script

First render the email template using the internal id. Then get the subject and body details of the email. Then replace the word using the replace method().

 // set email template

          let readyMergemail = render.mergeEmail({

            templateId: tempalte internal id;

          });

let emailId=”test@example.com”;

          let readyEmailSub = readyMergemail.subject;

          readyEmailSub = readyEmailSub.replace(“{Hi}”,”Hello”);

          let readyContent = readyMergemail.body;

          if (emailDataObj.tempEmailID){

            readyContent = readyContent.replace(“email”, ‘<a style=”color:blue;” href=”mailto:’ +emailId+ ‘”>’ + emailId + ‘</a>’)

}

Leave a comment

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