array in merge vars?

Oct 17, 2013 at 9:26 AM

I have the same problem as the guy in this post:

I need to pass an array of items into a merge var and what to know how to handle it.

The data is a table of reports and different recipients will receive a different number of rows and different data. I don't want any HTML in my code. I am hoping that Mandrill can do it in the template.

Any ideas anyone?

Nov 20, 2013 at 9:20 PM

Mandrill templates are very limited and cannot handle arrays. So the only way to do it is to build the HTML tables in your code and send that
to Mandrill.

I ended up using a Razor template inside my application that created the email and then a single merge var in Mandrill. This made it very easy
as Razor is very powerful and easy to work with.

Its a shame Mandrill templates aren't view engine templates like Razor. As they are they are very limited and useful only for injecting either
ready formed HTML or pieces of text. If you want tabular reports then you need another way.