email.sendCampaignEvent(options)

Method Description

Sends a single 'on-demand' campaign email to a specified recipient and return a campaign response ID to track the email. This is used for lead nurturing campaigns (drip marketing email).

Email (campaignemail) sublists are not supported. The campaign must use a Lead Nurturing (campaigndrip) sublist.

Note:

This API normally uses a bulk email server to send messages. If you need to increase the successful delivery rate of an email, use email.send(options) so that a transactional email server is used.

Returns

A campaign response ID (tracking code) as number

If the email fails to send, the value returned is -1.

Supported Script Types

Client and server scripts

For additional information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/email Module

Since

2015.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.campaignEventId

number

required

The internal ID of the campaign event.

Note:

This campaign must use a Lead Nurturing (campaigndrip) sublist. For more information about Lead Nurturing campaigns, see Lead Nurturing Campaigns.

2015.2

options.recipientId

number

required

The internal ID of the recipient.

Note:

The recipient's record must contain an email address.

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_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 10.0 MB.

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.<br/>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.

Note:

The following script includes sample values for some fields. You must replace these values with values from your NetSuite account for the code to process successfully.

          // Add additional code 
...
// Create a campaign record in dynamic mode so all field values can be dynamically sourced.
var campaign1 = record.create({
    type: record.Type.CAMPAIGN,
    isDynamic: true
});
campaign1.setValue({
    fieldId: 'title',
    value: 'Sample Lead Nurturing Campaign'
});
// set values on the Lead Nurturing (campaigndrip) sublist
campaign1.selectNewLine({
    sublistId: 'campaigndrip'
});
// 4 is a sample ID representing an existing marketing campaign
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'template',
    value: 4
}); 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'title',
    value: 'Sample Lead Nurturing Event'
}); 
// 1 is a sample ID representing an existing subscription 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'subscription',
    value: 1
}); 

// 2 is a sample ID representing an existing channel 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'channel',
    value: 2
}); 

// 1 is a sample ID representing an existing promocode 
campaign1.setCurrentSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'promocode',
    value: 1
}); 
campaign1.commitLine({
     sublistId: 'campaigndrip'
}); 

// Submit the record var 
campaign1Key = campaign1.save(); 

// Load the campaign record you created. Determine the internal ID of the campaign event to the variable campaign2_campaigndrip_internalid_1. 
var campaign2 = record.load({
    type: record.Type.CAMPAIGN,
    id : campaign1Key, 
    isDynamic: true
}); 
var campaign2_campaigndrip_internalid_1 = campaign2.getSublistValue({
    sublistId: 'campaigndrip',
    fieldId: 'internalid',
    line: 1
}); 
// 142 is a sample ID representing the ID of a recipient with a valid email address 
var campaignResponseId = email.sendCampaignEvent({
    campaignEventId: campaign2_campaigndrip_internalid_1,
    recipientId: 142
});
...
//Add additional code 

        

Related Topics

General Notices