MergeVars per recipient syntax for c#

Jan 19, 2013 at 10:45 PM

Hello all,

Im looking to start using this amazing mailchimp API to send emails using their mandrill service.  I have been able to get the emails sending ok using the below code. 

Would someone be able to copy and paste some code of how I would go about altering the below to add in the ability to add mergevars? 

	    var api = new MandrillApi("api");
            var recipients = new List();
            recipients.Add(new Mandrill.Messages.Recipient("email", "name"));

            var message = new Mandrill.Messages.Message()
            {
                To = recipients.ToArray(),
                FromEmail = "email from",
                FromName = "name from",
                Subject = "subject"
            };

Cheers

Coordinator
Jan 19, 2013 at 11:44 PM
Edited Jan 19, 2013 at 11:44 PM

Hi,
GlobalMergeVars is just an array of NameContentPairs.


using
M = MailChimp.Types.Mandrill; var message = new Mandrill.Messages.Message() { To = recipients.ToArray(), FromEmail = "email from", FromName = "name from", Subject = "subject", GlobalMergeVars = new [] { new M.NameContentPair<string>("MERGE1", "MERGE1") } };