Expand your SuiteScript skills in the Sustainable SuiteScript community for NetSuite developers.

SuiteScript Example - Sending Email to Multiple Recipients

Created: November 11, 2020

What good is an email you can only send to one person? How else would you catch people accidentally hitting "Reply All"? The N/email.send() method supports multiple recipients as well as CC and BCC functionality:

require(['N/email'], (email) => {
  email.send({
    author: -5,
    recipients: ['eric@stoic.software', 'aragorn@kingme.mid'],
    cc: [17, 'frodo@fly.fool'],
    bcc: ['s@iseeyou.morder', 21, 'notthegrey@eaglefriends.mid'],
    subject: 'Here Be Dragons',
    body: 'Like, really super big dragons'
  })
})

results in an email with a list of recipients:

Multiple recipients

The recipients property supports a single internal ID or a single email address string to send to one person, or an Array of those to send to multiple people. Here we have an Array containing two email addresses, thus our to line on the email will have these two recipient addresses.

CC and BCC

The send() method also provides the cc and bcc options to provide the corresponding functionality. These two properties behave identically to the recipients property in that they accept a single ID or address as well as an Array containing either or both.

cc: [17, 'frodo@fly.fool'] will CC both frodo@fly.fool as well as the Entity record with internal ID 17.

Similarly, bcc: ['s@iseeyou.mordor', 21, 'notthegrey@eaglefriends.mid'] will BCC three different email addresses: s@iseeyou.mordor, notthegrey@eaglefriends.mid, and the Entity record with internal ID 21.

Recipient Limit

Note that the send() method is limited to a maximum of 10 recipients across all of recipients, cc, and bcc.

If you need to send emails to larger audiences, such as with Marketing Campaigns, there are other methods within N/email for that purpose. Researching them on your own is a useful exercise.

HTH

-EG

This is a complete chapter from the Sending Email with SuiteScript Cookbook.