MailChimp.Net is licensed under the MIT license.
Install the NuGet package from the package manager console:
Install-Package MailChimp.Net.V3
Using it in code
using MailChimp.Net;
using MailChimp.Net.Interfaces;
IMailChimpManager manager = new MailChimpManager(apiKey); //if you have it in code
<add key="MailChimpApiKey" value="apiKEY" />
IMailChimpManager manager = new MailChimpManager(); //if you have it in config
Hint: MailChimp needs at least TLS 1.2. To use this library you have to set TLS 1.2 in ServicePointManager
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;
// Instantiate new manager
IMailChimpManager mailChimpManager = new MailChimpManager(apiKey);
var mailChimpListCollection = await this.mailChimpManager.Lists.GetAllAsync().ConfigureAwait(false);
var mailChimpListCollection = await this.mailChimpManager.Lists.GetAllAsync(new ListRequest
{
Limit = 50
}).ConfigureAwait(false);
var listId = "TestListId";
await this.mailChimpManager.Members.GetAllAsync(listId).ConfigureAwait(false);
var listId = "TestListId";
// Use the Status property if updating an existing member
var member = new Member { EmailAddress = $"githubTestAccount@test.com", StatusIfNew = Status.Subscribed };
member.MergeFields.Add("FNAME", "HOLY");
member.MergeFields.Add("LNAME", "COW");
await this.mailChimpManager.Members.AddOrUpdateAsync(listId, member);
// Get reference to existing user if you don't already have it
var listId = "TestListId";
var members = await this.mailChimpManager.Members.GetAllAsync(listId).ConfigureAwait(false);
var member = members.First(x => x.EmailAddress == "abc@def.com");
// Update the user
member.MergeFields.Add("FNAME", "New first name");
member.MergeFields.Add("LNAME", "New last name");
await this.mailChimpManager.Members.AddOrUpdateAsync(listId, member);
Tags tags = new Tags();
tags.MemberTags.Add(new Tag() { Name = "Awesome Person", Status = "active" });
await this.mailChimpManager.Members.AddTagsAsync(listId, "abc@def.com", tags);
To remove the tag, use "inactive" as the Status.
Progress on full implementation
Total 100%
This project exists thanks to all the people who contribute. [Contribute].
Thank you to all our backers! š [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]