Sending automated emails is one of the most common requirements in any NetSuite implementation. Whether you need to notify a team when a purchase order is approved, alert a customer when their shipment is dispatched, or send a scheduled report to management, the N/email module in SuiteScript 2.1 makes it straightforward. This guide covers everything you need to know to send emails effectively from your NetSuite scripts.
What Is the N/email Module?
The N/email module is a SuiteScript 2.1 API that allows scripts to send email messages directly from within NetSuite. It supports sending to internal NetSuite employees, external recipients, and distribution lists. Emails can include plain text or HTML bodies, file attachments from the File Cabinet, and can be sent on behalf of specific NetSuite users. It integrates tightly with NetSuite’s email tracking and audit trail features.
Sending a Basic Email with N/email
The simplest use case is sending a plain text or HTML email to one or more recipients. Here is how to do it in a Scheduled Script:
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/email', 'N/log', 'N/runtime'], (email, log, runtime) => {
const execute = (context) => {
try {
email.send({
author: runtime.getCurrentUser().id, // Current user as sender
recipients: ['manager@yourcompany.com'],
cc: ['team@yourcompany.com'],
subject: 'NetSuite Scheduled Report - ' + new Date().toDateString(),
body: '<h2>Daily Sales Summary</h2>' +
'<p>Please find the daily sales summary attached.</p>' +
'<p>Total Orders: 47<br>Total Revenue: $125,400</p>',
isInternalOnly: false
});
log.audit('Email Sent', 'Daily report email delivered successfully.');
} catch (e) {
log.error('Email Error', e.message);
}
};
return { execute };
});
Sending Emails with File Attachments
You can attach files from the NetSuite File Cabinet to your emails using the attachments parameter. Load the file with the N/file module first, then pass it directly to the email.send() call. This is especially useful for sending generated CSV reports, PDF invoices, or Excel exports.
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/email', 'N/file', 'N/log', 'N/runtime'], (email, file, log, runtime) => {
const execute = (context) => {
// Load an existing report file from the File Cabinet
const reportFile = file.load({ id: 5678 });
email.send({
author: runtime.getCurrentUser().id,
recipients: ['cfo@yourcompany.com'],
subject: 'Monthly Financial Report - May 2026',
body: '<p>Dear CFO,</p><p>Please find the monthly financial report attached for your review.</p><p>Best regards,<br>NetSuite Automation</p>',
attachments: [reportFile],
isInternalOnly: false
});
log.audit('Report Email Sent', 'Monthly financial report delivered to CFO.');
};
return { execute };
});
Sending Emails Using NetSuite Email Templates
For enterprise-level implementations, it is recommended to use NetSuite Email Templates instead of hardcoding HTML in your scripts. This separates the email design from the business logic and allows non-technical users to update email content without touching code. Use the email.sendBulk() or email.send() with a templateId parameter to reference a saved Email Template record in NetSuite.
define(['N/email', 'N/log', 'N/runtime'], (email, log, runtime) => {
const execute = (context) => {
// Send using a saved Email Template (Template Internal ID: 100)
email.send({
author: runtime.getCurrentUser().id,
recipients: ['customer@example.com'],
subject: 'Your Order Has Shipped!',
body: 'Your order has been dispatched and is on its way.',
templateId: 100, // Internal ID of Email Template record
relatedRecords: {
transactionId: 9999 // Link to a specific Transaction record
},
isInternalOnly: false
});
log.audit('Shipment Email', 'Customer shipping notification sent.');
};
return { execute };
});
Key Parameters of email.send()
Understanding all available parameters in email.send() will help you build more robust email automations. The author parameter accepts the internal ID of the NetSuite employee record that will appear as the sender. The recipients parameter accepts an array of email address strings or internal employee IDs. The cc and bcc parameters work the same way for carbon copy and blind carbon copy recipients. The replyTo parameter lets you specify a different reply-to address. Setting isInternalOnly to true means the email will not be sent to external addresses and will only appear in NetSuite’s internal communication log β useful for internal audit notes. The attachments parameter accepts an array of file.File objects loaded via the N/file module.
Governance and Best Practices
Each call to email.send() consumes governance units, so avoid sending emails inside loops over large datasets. Instead, batch your email notifications or use email.sendBulk() for mass communications. Always wrap email.send() in a try-catch block since delivery failures throw errors that will halt your script if unhandled. For high-volume notifications, consider using NetSuite’s built-in Workflow Actions or Mass Update features, which have dedicated email governance limits separate from SuiteScript. Also, test your HTML email bodies thoroughly across email clients since some clients strip certain CSS properties.
Conclusion
The N/email module is a powerful and flexible tool that enables NetSuite developers to build sophisticated automated communication workflows. From simple approval notifications to rich HTML reports with attachments, mastering N/email will make your NetSuite implementations significantly more responsive and user-friendly. If you have questions about email automation in NetSuite or want to share a real-world use case, post it in our community Q&A below!
Discover more from The NetSuite Pro
Subscribe to get the latest posts sent to your email.
Leave a Reply