email.send(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

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

N/email Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.author

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

options.body

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

options.recipients

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 (options.recipients + options.cc + options.bcc) is allowed.

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

options.subject

string

required

Subject of the outgoing message.

2015.2

options.attachments

| 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

options.bcc

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 (options.recipients + options.cc + options.bcc) is allowed.

2015.2

options.cc

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 (options.recipients + options.cc + options.bcc) is allowed.

2015.2

options.isInternalOnly

boolean

optional

If true, the Message record is not visible to an external Entity (for example, a customer or contact).

The default value is false.

2015.2

options.relatedRecords

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

options.replyTo

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
Note:

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 have the option to use multiple related records, but only one property value can be accepted for each related record.

There can be multiple related records, but only one of each parameter (each parameter represents applicable record types).

Parameter

Type

Required / Optional

Description

Since

activityId

number

optional

The Activity record to attach the Message record to.

Use for Case and Campaign record types.

2015.2

customRecord

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

customRecord.id

number

optional

The instance ID for the custom record to attach the Message record to.

Note:

If you use this parameter, customRecord.recordType is required.

2015.2

customRecord.recordType

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: /custrecordentry.nl?rectype=2&id=56.

Note:

If you use this parameter, customRecord.id is required.

2015.2

entityId

number

optional

The Entity record to attach the Message record to.

Use for all Entity record types (for example, customer, contact).

2015.2

transactionId

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

SSS_AUTHOR_MUST_BE_EMPLOYEE

The author internal id or email must match an employee.

The author internal ID or email address doesn't match an employee.

SSS_INVALID_TO_EMAIL

One or more recipient emails are not valid.

A recipient's email address is invalid.

SSS_INVALID_CC_EMAIL

One or more cc emails are not valid.

An email address specified in the options.cc parameter is invalid.

SSS_INVALID_BCC_EMAIL

One or more bcc emails are not valid.

An email address specified in the options.bcc parameter is invalid

SSS_MAXIMUM_NUMBER_RECIPIENTS_EXCEEDED

You may have a maximum number of 10 recipients.

A total number of recipients (options.recipients + options.cc + options.bcc) exceeds 10.

SSS_MISSING_REQD_ARGUMENT

{method name}: Missing a required argument: {param name}

A required parameter is missing.

WRONG_PARAMETER_TYPE

Wrong parameter type: {param name} is expected as {param type}.

A parameter's type is incorrect.

SSS_FILE_CONTENT_SIZE_EXCEEDED

The file content you are attempting to access exceeds the maximum allowed size of 10MB.

An attachment exceeds the 10 MB file size limit.

ATTACH_SIZE_EXCEEDED

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
Important:

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 

        

Related Topics

N/email Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices