When sending an email to multiple users from NetSuite through SuiteScript, there are several precautions and best practices to keep in mind:
- Limit on Recipients: NetSuite allows a maximum of 10 recipients (including recipient, cc, and bcc) for each email. If you need to send an email to more than 10 recipients, you may need to send multiple emails.
- Message Size: The total message size (including attachments) must be 20MB or less. The size of each attachment cannot exceed 10MB.
- Vicarious Email Permission: To send an email on another user’s behalf, the user triggering the email send must have a role with the Vicarious Email (ADMI_VICARIOUS_EMAIL) permission. If a user without this permission executes SuiteScript that sends an email, a Permission Violation error is returned.
- Recipient Parameter: The recipient parameter can take either an internal ID or an email address string¹. For multiple recipients, use an array of internal IDs or email addresses. Be careful when hard-coding any values in a script as this may result in future bugs if the email address ever changes.
- Use of Entity Groups: If you need to send an email to all users who have a specific role, consider creating a dynamic Entity Group based on a Saved Search of the Employees with this role. You can then set this Group as the recipient of your email.
- Email Content: The body of the email is where you can be creative! However, remember that SuiteScript formats the body of the email in either plain text or HTML. If HTML tags are present, the message is formatted as HTML. Otherwise, the message is formatted in plain text.
- Immutable Message Records: Message records can be edited only during the create operation. After they are created and submitted, existing message records cannot be edited.
Following is an example of an email send operation using the N/email module:
email.send({
author: senderEmployeeID,
recipients: recipientID,
subject: subjectString,
body: messageString
});