Skip to content

Repository files navigation

MailChimp.NET

.NET Wrapper for the MailChimp v2.0 API, built with MailChimp love ❤️

Build status

Quick Start

Install the NuGet package from the package manager console:

Install-Package MailChimp.NET

Next, you will need to provide MailChimp.NET with your API key in code. Need help finding your API key? Check here: http://kb.mailchimp.com/article/where-can-i-find-my-api-key

In your application, call:

// Pass the API key on the constructor:MailChimpManagermc=newMailChimpManager("YourApiKeyHere-us2");// Next, make any API call you'd like:ListResultlists=mc.GetLists();

Examples

Getting the first 100 users in each list:
usingMailChimp;usingMailChimp.Lists;MailChimpManagermc=newMailChimpManager("YourApiKeyHere-us2");ListResultlists=mc.GetLists();// For each listforeach(varlistinlists.Data){// Write out the list name:Debug.WriteLine("Users for the list "+list.Name);// Get the first 100 members of each list:MembersResultresults=mc.GetAllMembersForList(list.Id,"subscribed",0,100);// Write out each member's email address:foreach(varmemberinresults.Data){Debug.WriteLine(member.Email);}}
Subscribe an email address to a list:
MailChimpManagermc=newMailChimpManager("YourApiKeyHere-us2");//	Create the email parameterEmailParameteremail=newEmailParameter(){Email="customeremail@righthere.com"};EmailParameterresults=mc.Subscribe("YourListID",email);
Subscribe an email address to a list and set their interest groups (custom merge variables):
// create a class that inherits MergeVar and add any additional merge variable fields:[System.Runtime.Serialization.DataContract]publicclassMyMergeVar:MergeVar{[System.Runtime.Serialization.DataMember(Name="FNAME")]publicstringFirstName{get;set;}[System.Runtime.Serialization.DataMember(Name="LNAME")]publicstringLastName{get;set;}}MyMergeVarmyMergeVars=newMyMergeVar();myMergeVars.Groupings=newList<Grouping>();myMergeVars.Groupings.Add(newGrouping());myMergeVars.Groupings[0].Id=1234;// replace with your grouping idmyMergeVars.Groupings[0].GroupNames=newList<string>();myMergeVars.Groupings[0].GroupNames.Add("Your Group Name");myMergeVars.FirstName="Testy";myMergeVars.LastName="Testerson";MailChimpManagermc=newMailChimpManager("YourApiKeyHere-us2");//	Create the email parameterEmailParameteremail=newEmailParameter(){Email="customeremail@righthere.com"};EmailParameterresults=mc.Subscribe("YourListID",email,myMergeVars);
Getting location data for each list:
MailChimpManagermc=newMailChimpManager("YourApiKeyHere-us2");ListResultlists=mc.GetLists();// For each listforeach(varlistinlists.Data){Debug.WriteLine("Information for "+list.Name);// Get the location data for each list:List<SubscriberLocation>locations=mc.GetLocationsForList(list.Id);// Write out each of the locations:foreach(varlocationinlocations){Debug.WriteLine("Country: {0} - {2} users, accounts for {1}% of list subscribers",location.Country,location.Percent,location.Total);}}

Making contributions

This project is not affiliated with MailChimp. All contributors to this project are unpaid average folks (just like you!) who choose to volunteer their time. If you like MailChimp and want to contribute, we would appreciate your help! To get started, just fork the repo, make your changes and submit a pull request.

Also: If you're reading this and you're from MailChimp, we wouldn't mind some swag.

Status

Here is the progress so far (according to the MailChimp API docs ) :

Overall: 71% (78 of 109)

About

.NET Wrapper for the MailChimp v2.0 API

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages