email.sendCampaignEvent(options)

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

Sample code

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

Leave a comment

Your email address will not be published. Required fields are marked *