Send an email through loading an email template and replace the content of the email template.

Load an email template and read the content of the email template.

var template = record.load({

    type: record.Type.EMAIL_TEMPLATE,

    id: 124

});

var content = template.getValue({fieldId: 'content'});

Replace the content of the email template dynamically

content = content.replace(''{USERNAME}", "Vendor Name")

content = content.replace(''{TRANSACTIONNAME}", "Sales Order 123")

Sene email

email.send({

    author: senderId,

    recipients: recipientId,

    subject: 'Transaction Email',

    body: content

    }

});

Leave a comment

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