Skip to content

Instantly share code, notes, and snippets.

@FernandoVezzali
Last active June 27, 2018 09:56
Show Gist options
  • Save FernandoVezzali/6038304 to your computer and use it in GitHub Desktop.
Save FernandoVezzali/6038304 to your computer and use it in GitHub Desktop.
MailChimp example in C#
class Program
{
static void Main()
{
const string apiKey = "99999999999999999999999999999999-us2"; // Replace it before
const string listId = "b999jw9999"; // Replace it before
var options = new List.SubscribeOptions{DoubleOptIn = true,EmailType = List.EmailType.Html,SendWelcome = false};
var merges = new List<List.Merges> { new List.Merges("[email protected]", List.EmailType.Html) { { "FNAME", "John" }, { "LNAME", "Smith" } } };
var mcApi = new MCApi(apiKey, false);
var batchSubscribe = mcApi.ListBatchSubscribe(listId, merges, options);
if (batchSubscribe.Errors.Count > 0)
Console.WriteLine("Error:{0}", batchSubscribe.Errors[0].Message);
else
Console.WriteLine("Success");
Console.ReadKey();
}
}
@betalien
Copy link

Hi Fernardo!
I tried your code but is not working, in .NET side said that suscriber was added, but when i check in MailChimp List, the suscriber is not being added.

I download from nuget so in package config file i have the following:

I really appreciate if you can help me
Greetings from Chile!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment