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 (
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 |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
number |
required |
The internal ID of the campaign event.
Note:
This campaign must use a Lead Nurturing ( |
2015.2 |
|
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 |
---|---|---|
|
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 |
|
{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 10.0 MB. |
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.<br/>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.
The following script includes sample values for some fields. You must replace these values with values from your NetSuite account for the code to execute 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