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.

·3 min read·View Oracle Docs

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 NameReturn TypeSupported Script TypesDescription
email.send(options)voidClient and server scriptsSends transactional email to recipients and handles bounceback notifications. Requires Vicarious Email permission to send on behalf of others.
email.send.promise(options)voidClient scriptsSends transactional email asynchronously to recipients with bounceback notifications handled.
email.sendBulk(options)voidClient and server scriptsSends bulk email messages without needing bounceback notifications.
email.sendBulk.promise(options)voidClient scriptsSends bulk email messages asynchronously without requiring bounceback notifications.
email.sendCampaignEvent(options)numberClient and server scriptsSends a single 'on-demand' campaign email and returns a campaign response ID.
email.sendCampaignEvent.promise(options)numberClient and server scriptsSends a single 'on-demand' campaign email asynchronously, returning a campaign response ID.

Notes:

  • The send method 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.

suitescript
1/**
2 * @NApiVersion 2.1
3 */
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: true
13 });
14 recipient.setValue({
15 fieldId: 'subsidiary',
16 value: '1'
17 });
18 recipient.setValue({
19 fieldId: 'companyname',
20 value: 'Test Company' + timeStamp
21 });
22 recipient.setValue({
23 fieldId: 'email',
24 value: recipientEmail
25 });
26
27 let recipientId = recipient.save();
28
29 let fileObj = file.load({
30 id: 88
31 });
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.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

What permissions are required to send emails using the N/email module?
To send an email on behalf of another user using the N/email module, the script executor must have a role with the 'Vicarious Email (ADMI_VICARIOUS_EMAIL)' permission.
What is the maximum size for email attachments when using the N/email module?
The total message size, including attachments, must not exceed 15MB, with individual attachments not exceeding 10MB.
How does the N/email module handle bounce-back notifications?
The `email.send` and `email.send.promise` methods handle bounce-back notifications for transactional emails. The bulk email methods (`sendBulk` and `sendBulk.promise`) do not require bounce-back notifications.
Can the N/email module send campaign emails asynchronously?
Yes, the `email.sendCampaignEvent.promise` method allows campaign emails to be sent asynchronously, returning a campaign response ID.
Source: N/email Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →