Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

send a delivery with JS

Avatar

Level 4

How can i send a delivery with Javascript?

 

Example code please.

 

thanks

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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. 

 

View solution in original post

4 Replies

Avatar

Community Advisor

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>);

 

Avatar

Community Advisor

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_0-1680525903694.png

 

 

Avatar

Correct answer by
Employee Advisor

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.