N/email Module Methods for Email Management in NetSuite
The N/email module provides methods for sending transactional, bulk, and campaign emails within NetSuite, enhancing communication capabilities.
The N/email module in NetSuite allows developers and administrators to send various types of email messages directly from the platform. This functionality is essential not only for transactional emails but also for bulk communications and targeted campaign emails. Leveraging this module enhances user engagement and streamlines customer interactions.
What are the N/email Module Members?
The N/email module includes several methods for sending emails:
| Member Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
email.send(options) | void | Client and server scripts | Sends transactional email to recipients and handles bounceback notifications. Requires Vicarious Email permission to send on behalf of others. |
email.send.promise(options) | void | Client scripts | Sends transactional email asynchronously to recipients with bounceback notifications handled. |
email.sendBulk(options) | void | Client and server scripts | Sends bulk email messages without needing bounceback notifications. |
email.sendBulk.promise(options) | void | Client scripts | Sends bulk email messages asynchronously without requiring bounceback notifications. |
email.sendCampaignEvent(options) | number | Client and server scripts | Sends a single 'on-demand' campaign email and returns a campaign response ID. |
email.sendCampaignEvent.promise(options) | number | Client and server scripts | Sends a single 'on-demand' campaign email asynchronously, returning a campaign response ID. |
Notes:
- The
sendmethod can handle up to 10 recipients simultaneously, including CC and BCC. - The total message size, including attachments, must not exceed 15MB, and individual attachments cannot exceed 10MB.
Who Can Send Emails?
To send an email on another user's behalf, the script executor must possess a role with the Vicarious Email (ADMI_VICARIOUS_EMAIL) permission. If a user lacking this permission runs the script and attempts to send an email, a Permission Violation error will occur.
Sample Code for Sending an Email
To highlight the capabilities of the N/email module, below is a sample script that demonstrates how to send an email with an attachment. Note that the valid IDs and file paths need to be used in your NetSuite account.
1/**2 * @NApiVersion 2.13 */4 5require(['N/email', 'N/record', 'N/file'], (email, record, file) => {6 const senderId = -515;7 const recipientEmail = 'notify@myCompany.com';8 let timeStamp = new Date().getUTCMilliseconds();9 10 let recipient = record.create({11 type: record.Type.CUSTOMER,12 isDynamic: true13 });14 recipient.setValue({15 fieldId: 'subsidiary',16 value: '1'17 });18 recipient.setValue({19 fieldId: 'companyname',20 value: 'Test Company' + timeStamp21 });22 recipient.setValue({23 fieldId: 'email',24 value: recipientEmail25 });26 27 let recipientId = recipient.save();28 29 let fileObj = file.load({30 id: 8831 });32 33 email.send({34 author: senderId,35 recipients: recipientId,36 subject: 'Test Email',37 body: 'This is a test email with an attachment.',38 attachments: [fileObj]39 });40});This reusable script can be adapted to fit your specific email sending needs.
Key Considerations
- Always ensure that the correct permissions are assigned before executing email scripts.
- Validate recipient information to avoid errors during email sending.
- Consider the governance units utilized when sending emails to optimize your scripting approach.
Frequently Asked Questions (4)
What permissions are required to send emails using the N/email module?
What is the maximum size for email attachments when using the N/email module?
How does the N/email module handle bounce-back notifications?
Can the N/email module send campaign emails asynchronously?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
