Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Sending emails through API

Ramaswami
Level 4
Level 4

Hi Team, 

 

I am seding emails through javascript API like the below : 

 

Ramaswami_0-1605188912188.png

 

in my javascript code : 

 

var emailCondition = "@email = 'abc@gmail.com'";

var deliveryId = nms.delivery.SubmitNotification ("prdDM30608",
<delivery>
<targets >
<deliveryTarget >
<targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={emailCondition} />
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>);
logInfo("deliveryid : "+deliveryId)

 

Currently it is taking the email address statically. I want the email address to be taken dynamically from the query activity. How can i do that ?

 

solution which I am following ( but i don't think so this is a nice solution as when i follow this solution the exclude duplicate option in the email settings not working)

 

Solution which i am thinking is a wrong approach : 

// vars.tableName = table which is generated by query activity and it has email column

var cnx = application.getConnection();

var details = cnx.query("select * from "+vars.tableName);
for each(var row in details)
{
var emailCondition = "@email = '"+row[1]+"'";
var deliveryId = nms.delivery.SubmitNotification ("prdDM30608",
<delivery>
<targets >
<deliveryTarget >
<targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={emailCondition} />
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>);
logInfo("deliveryid : "+deliveryId)
}
cnx.dispose();

 

Is there any good approach to directly pipe the email from query activity this way i can exclude duplicate addresses for emails. 

 

Question 2: 

Also if in email template if we have a variable piping like "<%=recipient.firstname>" how can i pass this varable from api call ?? any solution for this??

 

1 Accepted Solution
DavidKangni
Correct answer by
Community Advisor
Community Advisor

You should use message center for this cases if you want your recipient/user to receive an email after your api call. 

from the marketing instance, i will recommend to send api call to recipient table and trigger a workflow every 10-15 min.

 

Thanks

David

View solution in original post

2 Replies
DavidKangni
Correct answer by
Community Advisor
Community Advisor

You should use message center for this cases if you want your recipient/user to receive an email after your api call. 

from the marketing instance, i will recommend to send api call to recipient table and trigger a workflow every 10-15 min.

 

Thanks

David

View solution in original post

Ramaswami
Level 4
Level 4

Hi @DavidKangni,

 

I am new to this. Can you give me an example ?

 

Currently i am able to send the deliveries through API but there are some variables of recipient table which i need to pass to delivery template like ( recipient.firstname) how can i do so ?

 

along with email i need to pass two more variables of recipient table.

 

Currently this is my code : 

 

// vars.tableName = table which is generated by query activity and it has email column

var cnx = application.getConnection();

var details = cnx.query("select * from "+vars.tableName);
for each(var row in details)
{
var emailCondition = "@email = '"+row[1]+"'";
var deliveryId = nms.delivery.SubmitNotification ("prdDM30608",
<delivery>
<targets >
<deliveryTarget >
<targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={emailCondition} />
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>);
logInfo("deliveryid : "+deliveryId)
}
cnx.dispose();