email.send(options)
Method Description |
Sends email to an individual or group of recipients and receives bounceback notifications. A maximum of 10 recipients (recipient +cc +bcc) is allowed. The total message size (including attachments) must be 15MB or less. The size of each attachment cannot exceed 10MB.
Note:
To send 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 email, a Permission Violation error is returned. |
Returns |
void |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Governance |
20 units |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
number |
required |
Internal ID of the email sender. To find the internal ID of the send in the UI, go to Lists > Employees. If the ADMI_VICARIOUS_EMAILS permission is set, the sender ID can be set to a different sender to allow users to send email on another user's behalf. The role executing the script is required to have the Vicarious Email permission for the script to complete. For more information about permissions, see the help topic NetSuite Permissions Overview. |
2015.2 |
|
string |
required |
Contents of the outgoing message. 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. To display XML as plain text, use an HTML <pre> tag around the XML. |
2015.2 |
|
number | string | number[] | string[] |
required |
The internal ID or email address of the recipient(s). For multiple recipients, use an array of internal IDs or email addresses. You can use an array that contains a combination of internal IDs and email addresses. A maximum of 10 recipients (
Note:
Only the first recipient displays on the Communication tab (under the Recipient column). To view all recipients, click View to open the Message record. |
2015.2 |
|
string |
required |
Subject of the outgoing message. |
2015.2 |
|
| file.File[] |
optional |
Email file attachments. You can send multiple attachments of any media type. An individual attachment must not exceed 10MB and the total message size must be 15MB or less.
Note:
Supported for server scripts only. |
2015.2 |
|
number[] | string[] |
optional |
The internal ID or email address of the recipient(s) to blind copy. For multiple recipients, use an array of internal IDs or email addresses. You can use an array that contains a combination of internal IDs and email addresses. A maximum of 10 recipients ( |
2015.2 |
|
number[] | string[] |
optional |
The internal ID or email address of the secondary recipient(s) to copy. For multiple recipients, use an array of internal IDs or email addresses. You can use an array that contains a combination of internal IDs and email addresses. A maximum of 10 recipients ( |
2015.2 |
|
boolean |
optional |
If true, the Message record is not visible to an external Entity (for example, a customer or contact). The default value is |
2015.2 |
|
Object |
optional |
Object that contains key-value pairs to associate (attach) the Message record with related records (that is, transaction, activity, entity, and custom records). See the relatedRecords table for more information. |
2015.2 |
|
string |
optional |
The email address that appears in the reply-to header. You can use either a single external email address or a generic email address created by the Email Capture Plug-in. |
2015.2 |
relatedRecords
The relatedRecords parameter is a JavaScript object.
Represents the NetSuite records to which an email Message record should be attached. You can associate the sent email with the following records listed below. You cannot use custom record, transaction, and activity together as an email related record; these three records are mutually exclusive.
Only entityId
is compatible with other records
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
number |
optional |
The Activity record to attach the Message record to. Use for Case and Campaign record types. |
2015.2 |
|
Object |
optional |
The custom record to attach the Message record to. For custom records you must specify both the record ID and the record type ID. The custom record is linked by using a nested JavaScript object. |
2015.2 |
|
number |
optional |
The instance ID for the custom record to attach the Message record to.
Note:
If you use this parameter, |
2015.2 |
|
string |
optional |
The integer ID for the custom record type to attach the Message record to. This ID is shown as part of the record’s URL. For example:
Note:
If you use this parameter, |
2015.2 |
|
number |
optional |
The Entity record to attach the Message record to. Use for all Entity record types (for example, customer, contact). |
2015.2 |
|
number |
optional |
The Transaction record to attach the Message record to. Use for transaction and opportunity record types. |
2015.2 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
The author internal id or email must match an employee. |
The author internal ID or email address doesn't match an employee. |
|
One or more recipient emails are not valid. |
A recipient's email address is invalid. |
|
One or more cc emails are not valid. |
An email address specified in the |
|
One or more bcc emails are not valid. |
An email address specified in the |
|
You may have a maximum number of 10 recipients. |
A total number of recipients ( |
|
{method name}: Missing a required argument: {param name} |
A required parameter is missing. |
|
Wrong parameter type: {param name} is expected as {param type}. |
A parameter's type is incorrect. |
|
The file content you are attempting to access exceeds the maximum allowed size of 10MB. |
An attachment exceeds the 10 MB file size limit. |
|
This message exceeds the limit of 15 MB. Please reduce the size of the message and its attachments and try again. Note: Files can be larger when attached due to encoding. |
The size of the attachments exceeds the limit. |
Syntax
The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/email Module Script Sample.
//Add additional code
.
var senderId = -5;
var recipientEmail = 'notify@myCompany.com';
var timeStamp = new Date().getUTCMilliseconds();
var recipientId = 12;
var fileObj = file.load({
id: 88
});
email.send({
author: senderId,
recipients: recipientId,
subject: 'Test Sample Email Module',
body: 'email body',
attachments: [fileObj],
relatedRecords: {
entityId: recipientId,
customRecord:{
id:recordId,
recordType: recordTypeId //an integer value
}
}
});
...
//Add additional code