Example for passing First Name and Last Name on Subscribe with MailChimp.net

StackOverflow https://stackoverflow.com/questions/22432402

  •  15-06-2023
  •  | 
  •  

سؤال

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?

هل كانت مفيدة؟

المحلول 2

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; }
}

نصائح أخرى

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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top