Reputation: 35
I have successfully implemented subscriptions with MailChimp.net but it is email only. Does anyone have an example of how to pass firstname and lastname when subscribing?
Upvotes: 2
Views: 1151
Reputation: 31
Create a new instance of MergeVar and simply add the list field tag (key) along with its value.
Then pass the MergeVar instance as a parameter into the Subscribe method.
MailChimpManager mc = new MailChimpManager("API Key");
EmailParameter emailParam = new EmailParameter()
{
Email = HttpUtility.HtmlEncode(email)
};
MergeVar mV = new MergeVar();
mV.Add("FNAME", HttpUtility.HtmlEncode(firstName));
mV.Add("LNAME", HttpUtility.HtmlEncode(lastName));
EmailParameter results = mc.Subscribe("List ID", emailParam, mV);
Upvotes: 3
Reputation: 1101
Create your own MergeVar and use it in the Subscribe method
[DataContract]
public class CustomMergeVar : MergeVar
{
[DataMember(Name = "FNAME")]
public string FirstName { get; set; }
[DataMember(Name = "LNAME")]
public string LastName { get; set; }
[DataMember(Name = "ORGANIS")]
public string Organisation { get; set; }
}
Upvotes: 1