📧 Basic Email Sending
The N/email module provides email.send() for transactional emails from scripts:
const email = require('N/email');
email.send({
author: 207, // Employee internal ID
recipients: 'customer@example.com',
subject: 'Your Order Confirmation',
body: 'Thank you for your order!'
});Key Parameters
| Parameter | Type | Description |
|---|---|---|
| author | Number | Employee internal ID (sender) |
| recipients | String/Array | Email addresses or entity IDs (max 10) |
| subject | String | Email subject line |
| body | String | Plain text or HTML content |
| cc | String/Array | CC recipients (optional) |
| bcc | String/Array | BCC recipients (optional) |
⚠️ Recipient Limit
Maximum 10 recipients total across to, cc, and bcc fields. For bulk emails, use N/email.sendBulk() or a marketing platform.
📎 Attachments
Attach files from the File Cabinet:
const file = require('N/file');
const attachment = file.load({ id: 12345 });
email.send({
author: 207,
recipients: 'customer@example.com',
subject: 'Your Report',
body: 'Please find your report attached.',
attachments: [attachment]
});🔗 Linking to Records
Use relatedRecords to link emails to transactions for activity tracking:
email.send({
author: 207,
recipients: customerId, // Can use entity internal ID
subject: 'Order #' + orderNumber,
body: emailBody,
relatedRecords: {
transactionId: salesOrderId,
entityId: customerId
}
});✅ Activity Tracking
When you link an email to a record, it appears in the record's Communication subtab and Activity History, providing a complete audit trail.
🎨 HTML Emails
Send formatted HTML content:
const htmlBody = `
<h1 style="color: #333;">Order Confirmation</h1>
<p>Thank you for your order, ${customerName}!</p>
<table>
<tr><td>Order Number:</td><td>${orderNumber}</td></tr>
<tr><td>Total:</td><td>${orderTotal}</td></tr>
</table>
`;
email.send({
author: 207,
recipients: customerEmail,
subject: 'Order Confirmation',
body: htmlBody
});📖 Finding This in the Docs
To look up N/email methods:
- Go to docs.oracle.com → SuiteScript 2.x Modules
- Click on N/email Module
- Review email.send() parameters and relatedRecords options
Key pages to bookmark:
- email.send(options) → author, recipients, subject, body, attachments
- email.sendBulk(options) → for mass email campaigns
- RelatedRecords object → transactionId, entityId, activityId
- N/file Module → for creating attachments
🎯 Key Takeaways
- email.send() requires author (employee ID), recipients, subject, and body
- Author must be an employee internal ID, not an email address
- Maximum 10 recipients across to, cc, and bcc
- Use relatedRecords to link emails to transactions and entities
- Attachments require file.load() to get the file object
- HTML content works in the body parameter
- Consumes 10 governance units per email