I am working on sending transactional emails to our recipients according to visitors activity in the last week, such that I'll want to deliver at the end the following email including 12 profiles maximum:
Hi, User, bla bla look these profiles:
Visitor's Name, Age, link to Visitor's image
Maria , 39 , http://images.fixapp.com/t-16985.jpg
*
* 12 profiles
*
Elena , 33, http://images.fixapp.com/t-16915.jpg
Click here to see all your visitors profiles
So far I advanced very well with the task doing the following:
<div class="new__faces__img"><img src='[[data:visitor1.photo]]'></div>
<div class="new__faces__name">
<span>[[data:visitor1.name]]</span>, [[data:visitor1.age]]
</div>
> other visitors ...
<div class="new__faces__img"><img src='[[data:visitor12.photo]]'></div>
<div class="new__faces__name">
<span>[[data:visitor12.name]]</span>, [[data:visitor12.age]]
</div>
What I still don't know is how to handle the case when a user has less than 12 visitors. Mandrill email service in such cases offers conditional merge tags. What is the way of MailJet to resolve the issue?
I'm leading Developers Relations at Mailjet. First of all, thanks for your interest in our API!
At the moment, our system doesn't support object properties so you won't be able to use them as featured in your HTML code, like visitor1.photo
. To represent such data you can create metadata for each visitor's information, like visitor1_photo or visitor1_age.
From there, you'll be able to use it in your HTML code like you're doing in your example.
We're in the process of developing advanced Templating features. Meanwhile, the best way would be to pre-process the message on your side to generate the final template and send it via our Send API or SMTP.
You can get the same behaviour than a Marketing Campaign by using the X-Mailjet-Campaign SMTP header (mj-campaign in the Send API) to group messages under the same campaign.
Hope it helps!