NetSuite’s email.sendBulk() function allows you to send bulk emails to multiple recipients in a single operation, unlike the more commonly used email.send(). This is especially useful for sending notifications, alerts, or updates to multiple users at once. In the example below, emails are sent to a list of recipients, with the system user (-5) as the author.
Example:
define(['N/email'], function(email) {
function sendBulkEmails() {
var recipientEmails = [
'msample@netsuite.com',
'jdoe@netsuite.com',
'awolfe@netsuite.com',
'htest@netsuite.com'
];
email.sendBulk({
author: -5,
recipients: recipientEmails,
subject: 'Order Status',
body: 'Your order has been completed.',
replyTo: 'accounts@netsuite.com'
});
}
});
email.sendBulk() sends the same email to multiple recipients at once.
The author: -5 sets the sender to the system user.
This method is ideal for efficiently distributing messages to large groups of users.