Can I use system email templates on SuiteScript?
# ask-stanley-ai
e
Can I use system email templates on SuiteScript?
c
AI generated answer (using internal Slack threads):
Yes, you can use system email templates in SuiteScript. You can use the
render.mergeEmail
method to merge an email template with a record. This method returns an object that contains the subject and body of the email, which you can then use to send the email. Here is an example of how you can use it:
Copy code
javascript
var mergeResult = render.mergeEmail({
    templateId: 123, // replace with your template id
    entity: {
        type: record.Type.CUSTOMER,
        id: 456 // replace with your record id
    }
});

var emailSubject = mergeResult.subject;
var emailBody = mergeResult.body;

// send the email using N/email module
email.send({
    author: 789, // replace with your author id
    recipients: '<mailto:test@example.com|test@example.com>',
    subject: emailSubject,
    body: emailBody
});
Please replace the ids in the example with your actual ids. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.88158673
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858384907
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852413893
Please provide your feedback on this answer.