Hello everyone,
I'm attempting to create dynamic deliveries containing personalized attachments and HTML content for each recipient. I've tried achieving this by selecting depending on recipient profiles in delivery, but I haven't been successful in testing it.
So, I've decided to use JavaScript instead. With the code below, I've managed to personalize content and attachments for a single customer. However, I want to extend this to all my recipients. I need one delivery that contains all my recipients, with each receiving individual personalized attachments and content.
Could anyone help me sort this out?
var rId = '1234';
var subjectLine = 'Hi im working';
var xmlTargeting = <delivery>
<targets >
<deliveryTarget>
<targetPart exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={'@id=' + rId}/> // Recipient ID
</where>
</targetPart>
</deliveryTarget>
</targets>
<mailParameters>
<subject>{subjectLine}</subject>
</mailParameters>
</delivery>;
var template = 'tempInternalName';
var finalDev = nms.delivery.CreateFromModel(template, xmlTargeting); // Delivery Template internal name
var deliv = nms.delivery.create(finalDev);
deliv.scheduling.validationMode = "auto";
deliv.validation.useBudgetValidation = false;
deliv.validation.useContentValidation = false;
deliv.validation.useTargetValidation = false;
deliv.validation.useFCPValidation = false;
deliv.content.html.source = '<html> <body>Hello Test</body> </html>';
var recId = 'test_1234';
deliv.attachment.add(
<attachment compressMode="print" filterActive="false" label="CRM test.csv"
nameScriptActive="false" type="normal" upload="false">
<name>C:\Program Files (x86)\Adobe\Adobe Campaign v7\var\cc_sandbox\export\{recId}.txt</name>
</attachment>
)
deliv.hasAttachments = true;
deliv.save();
nms.delivery.PrepareFromId(deliv.id);
Regards,
Sujith Kumar.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
You've two things to do:
<where>
<condition expr={'@id=' + rId}/> // Recipient ID
</where>
This is where the query to recipients is being made, you've to change it so it gets all the recipients you want (If you want to get all recipients you should remove this where condition).
Second, here:
deliv.content.html.source = '<html> <body>Hello Test</body> </html>';
You've to add the personalization fields you want. This is the literal message that will be sent, so if you add something like
<%= recipient.firstName%>
It will be personalized in each delivery.
You've two things to do:
<where>
<condition expr={'@id=' + rId}/> // Recipient ID
</where>
This is where the query to recipients is being made, you've to change it so it gets all the recipients you want (If you want to get all recipients you should remove this where condition).
Second, here:
deliv.content.html.source = '<html> <body>Hello Test</body> </html>';
You've to add the personalization fields you want. This is the literal message that will be sent, so if you add something like
<%= recipient.firstName%>
It will be personalized in each delivery.
Hi @CampaignerForLife ,
Sorry for late reply. I was looking for dynamic attachment it may be any type. Thanks for your reply I solved it using file class js.
Regards,
Sujith Kumar
Views
Replies
Total Likes