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
}
});