send a delivery with JS | Community
Skip to main content
alnavarg
Level 4
April 3, 2023
Solved

send a delivery with JS

  • April 3, 2023
  • 2 replies
  • 1820 views

How can i send a delivery with Javascript?

 

Example code please.

 

thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by akshaaga

Hi @alnavarg,

To send a delivery in Adobe Campaign using JavaScript, you can use the SOAP API provided by Adobe Campaign.

Here is an example code snippet to create a delivery:

// Set up the SOAP client

var soap = require('soap');

var url = 'https://example.com/nl/jsp/soaprouter.jsp?wsdl';

var options = {

  forceSoap12Headers: true

};

var client = await soap.createClientAsync(url, options);

// Set up the delivery properties

var delivery = {

  name: 'My Delivery',

  label: 'My Delivery Label',

  startDate: new Date(),

  endDate: new Date(),

  content: {

    type: 'Delivery',

    htmlBody: '<html><body>Hello World!</body></html>'

  }

};

// Create the delivery

var result = await client.createAsync({ delivery: delivery });

console.log(result);

 

This code sets up a SOAP client using the soap library, sets the properties of the delivery, and then calls the createAsync method of the SOAP client to create the delivery.

Note that this is just a basic example and you may need to modify the code depending on your specific requirements and the configuration of your Adobe Campaign instance. 

 

2 replies

ParthaSarathy
Community Advisor
Community Advisor
April 3, 2023

Hi @alnavarg ,

Create a new delivery template and in its property Analysis tab > set approval mode as Automatic.

In workflow JavaScript try below script,

var subjectLine = "Subject Line"; var emailBody = "<html><body><p>Email Body Content</p></body></html>"; var recipientID = "123456789"; var deliveryId = nms.delivery.SubmitDelivery("internalNameOfDeliveryTemplate",<delivery> <targets > <deliveryTarget> <targetPart exclusion='false' ignoreDeleteStatus='false'> <where> <condition expr={'@id ='+recipientID}/> </where> </targetPart> </deliveryTarget> </targets> <mailParameters> <subject>{subjectLine}</subject> </mailParameters> <content> <html> <source>{emailBody}</source> </html> </content> </delivery>);

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
alnavarg
alnavargAuthor
Level 4
April 3, 2023

Yes but i want to send it

 

 

ParthaSarathy
Community Advisor
Community Advisor
April 3, 2023

The above JS had triggered email to the recipient with primary Key 123456789.

You can modify the where condition to target recipients as per requirement. 

 

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
akshaaga
Adobe Employee
akshaagaAdobe EmployeeAccepted solution
Adobe Employee
April 3, 2023

Hi @alnavarg,

To send a delivery in Adobe Campaign using JavaScript, you can use the SOAP API provided by Adobe Campaign.

Here is an example code snippet to create a delivery:

// Set up the SOAP client

var soap = require('soap');

var url = 'https://example.com/nl/jsp/soaprouter.jsp?wsdl';

var options = {

  forceSoap12Headers: true

};

var client = await soap.createClientAsync(url, options);

// Set up the delivery properties

var delivery = {

  name: 'My Delivery',

  label: 'My Delivery Label',

  startDate: new Date(),

  endDate: new Date(),

  content: {

    type: 'Delivery',

    htmlBody: '<html><body>Hello World!</body></html>'

  }

};

// Create the delivery

var result = await client.createAsync({ delivery: delivery });

console.log(result);

 

This code sets up a SOAP client using the soap library, sets the properties of the delivery, and then calls the createAsync method of the SOAP client to create the delivery.

Note that this is just a basic example and you may need to modify the code depending on your specific requirements and the configuration of your Adobe Campaign instance.