MailChimp.NET
MailChimp.NET copied to clipboard
Groupings and GroupInterests
I am not sure if I am trying to create a Grouping with GroupInterests correctly. I keep getting a "An exception of type 'System.NullReferenceException' occurred in myproject.DLL but was not handled in user code". Here's a sample of my code:
// Create and populate Groupings for Giving Interests then add to MergeVar
MailChimp.Lists.Grouping givingGroup = new MailChimp.Lists.Grouping();
givingGroup.Name = "GIVING_INTERESTS";
// Interest list is a comman delimited list in the GIVING_INTERESTS field in the SPROC
List<string> groupInterests_GI = row["GIVING_INTERESTS"].ToString().Split(',').ToList<string>();
for (int i = 0; i < groupInterests_GI.Count; i++)
{
MailChimp.Lists.Grouping.GroupInterest interest = new MailChimp.Lists.Grouping.GroupInterest();
interest.Name = groupInterests_GI[i].ToString();
interest.Interested = true;
givingGroup.GroupInterests.Add(interest);
}
what am I doing wrong?