Skip to content

Repository files navigation

MailChimp.Net - A Mail Chimp 3.0 Wrapper

Backers on Open Collective Sponsors on Open Collective

License

MailChimp.Net is licensed under the MIT license.

Quick Start

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;

Examples

// Instantiate new manager
IMailChimpManager mailChimpManager = new MailChimpManager(apiKey);
Getting all lists:
var mailChimpListCollection = await this.mailChimpManager.Lists.GetAllAsync().ConfigureAwait(false);
Getting 50 Lists:
var mailChimpListCollection = await this.mailChimpManager.Lists.GetAllAsync(new ListRequest
                                                               {
                                                                   Limit = 50
                                                               }).ConfigureAwait(false);
Getting Users from List:
var listId = "TestListId";
await this.mailChimpManager.Members.GetAllAsync(listId).ConfigureAwait(false);
Adding New User To List
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);
Updating An Existing User
// 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);
Adding/Removing a Tag From a User
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.

Status

Full Mailchimp Marketing API coverage (models, interfaces, and logic wired on IMailChimpManager).

Target frameworks: net45, net472, netstandard1.3, netstandard2.0, net10.0

TFM JSON serializer Newtonsoft.Json Microsoft.Extensions.*
net45 Newtonsoft.Json 13.0.4 Yes β€”
net472 Newtonsoft.Json 13.0.4 Yes 10.0.10
netstandard1.3 Newtonsoft.Json 13.0.4 Yes 1.1.2 (last line supporting netstandard1.x)
netstandard2.0 Newtonsoft.Json 13.0.4 Yes 10.0.10
net10.0 System.Text.Json None 10.0.10

Models use library-local [MailChimpJsonProperty] / [MailChimpJsonConverter] attributes. Legacy TFMs map those through a Newtonsoft contract resolver; net10.0 maps them through System.Text.Json type-info modifiers. API JSON shapes stay aligned across TFMs, and net10.0 has no Newtonsoft dependency at compile time or runtime.

  • API / Ping 100%
  • Account Exports 100%
  • Audiences / Contacts (BETA) 100%
  • Authorized Apps 100%
  • Automation flows / Customer Journeys (trigger) 100%
  • Classic Automations (+ create/archive, email update/delete) 100%
  • Batch Operations 100%
  • Batch Webhooks 100%
  • Campaigns (+ search, pause/resume/create-resend) 100%
  • Campaign Content 100%
  • Campaign Feedback 100%
  • Campaign Folders 100%
  • Campaign Send Checklist 100%
  • Connected Sites 100%
  • Conversations 100% (obsolete β€” prefer Mailchimp Inbox)
  • Conversations Messages 100% (obsolete β€” prefer Mailchimp Inbox)
  • E-commerce Stores 100%
  • E-commerce Carts / Customers / Orders / Order Lines 100%
  • E-commerce Products / Variants / Images 100%
  • E-commerce Promo Rules / Codes 100%
  • E-commerce account-level Orders + PUT upserts 100%
  • Facebook Ads 100%
  • File Manager Files / Folders / Files-in-Folder 100%
  • Landing Pages (+ content, publish/unpublish) 100%
  • Lists / Audiences 100%
  • List Abuse Reports / Activity / Clients / Growth History 100%
  • List Interest Categories / Interests 100%
  • List Locations 100%
  • List Members (+ goals, activity feed, tags, events) 100%
  • List Segments / Merge Fields / Signup Forms / Surveys / Webhooks 100%
  • Reporting (landing pages, surveys, facebook ads) 100%
  • Reports (campaign) + ecommerce product activity 100%
  • Search Campaigns / Search Members 100%
  • SMS Campaigns (+ content/actions) 100%
  • Template Folders / Templates / Default Content 100%
  • Verified Domains 100%

Total 100%

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! πŸ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

About

Mail Chimp 3.0 Wrapper

Topics

Resources

Stars

324 stars

Watchers

24 watching

Forks

Releases

Packages

Used by

Contributors

Languages