Working With The MailChimp API In .NET: Overview And Setup

This is the first in a series of posts about the MailChimp.NET.V3 wrapper library.

My employer puts a lot of emphasis on email marketing through MailChimp. Some of our most successful email products are RSS-driven campaigns that send out selected daily headlines every morning.

These newsletters have thousands of subscribers. Some of whom, occasionally, manage to unsubscribe unintentionally; either through reporting one of our emails as spam, or by clicking the unsubscribe link that MailChimp (rightly) requires in every message we send.

To these users, it often appears as though the daily emails they had been getting have stopped mysteriously; a problem they report to our circulation department’s customer service representatives. Who, in turn, report the problem to me. Who, in turn, has to log in to our MailChimp dashboard, find the affected customer, and edit his record.

Needless to say, this was an inefficient system.

In addition to disempowering the customer service representative — who should have the ability to resolve subscriber delivery complaints of all shades — it required the customer service encounter to be suspended, which is never desirable; problems should be solved during the initial contact.

And even more so, it had me wading around in the MailChimp dashboard when I could be doing any number of things I’d prefer to be doing.

So it was time to engineer a solution that would allow our customer service representatives to solve these mailing list subscription problems while the customer was still on the line / in the initial response to the customer’s emailed inquiry.

Which is to be the subject of this post.

Azure Web App

The solution I settled upon was to spin up a Web App in Azure with an ASP.NET MVC solution as a GUI, and use the MailChimp.Net.V3 wrapper library by Brandon Seydel to leverage the MailChimp REST API version 3.

Azure Web Apps are basically anonymous server instances (platform as a service) tuned to perform IIS tasks.

I like them for a number of reasons, but in this case, specifically because my employer also uses Office 365. That means our Azure subscription includes access to our Office 365 Active Directory; which, in turn, means I can easily authenticate users against AD right from the Azure Web App, since authentication via organizational accounts is a black box in Visual Studio.

In other words, I can easily limit access to tools I put in a Web App to just those people with an Office 365 account. And I can read directory info, and further limit access to certain AD groups.

Since I have tons of experience with ASP.NET, and since I am never sure who within our circulation customer service department is going to need to access this tool, it’s super-convenient to put it out on the web and lock it down with Active Directory.


With the GUI concerns solved, I next needed a tool to interface with the MailChimp API.

Of course, it’s well within the capacity of ASP.NET to make REST requests without a wrapper or other means of abstracting the MailChimp API. It’s just a lot more difficult than using a wrapper, and it means writing a lot of code that doesn’t really have to do with the problem at hand (read: reinventing a lot of wheels).

I came across Brandon Seydel’s MailChimp.NET.V3 library after a nuget search, and it implements fairly well all the API methods I need to use. Namely, that’s list management; and more importantly, managing the members and segments for a list.


So with the framework for this problem on hand, I next needed to define what the solution could do.

  • I needed to show our customer service people when the last time each of these newsletter RSS campaigns was last sent. If they saw a spike in complaints from people about not getting a newsletter, customer service needed to verify that the campaign was actually sent. Because sometimes, if the moon and stars are out of alignment, MailChimp won’t send an RSS-driven campaign.
  • Customer service needed to be able to look up a user by email address, and see her subscription status for a specific newsletter list (e.g., subscribed; unsubscribed; cleaned; pending).
  • If a user is unsubscribed, cleaned or pending, customer service needed to be able to re-subscribe that user to a list.
  • If a user is subscribed, customer service needs to be able to manage the list segments to which that user’s email address belongs. We use the same master list for all newsletter subscribers, and send specific newsletters to segments of that list. For example, our daily headlines newsletters and breaking news newsletters are different segments of the same master list.
  • Customer service needs to be able to unsubscribe a user from a list.
  • If a user isn’t in the specified MailChimp list, we need to add that user to the list.

All of these, except for managing the list segments to which a subscriber belongs, are easily accomplished via the MailChimp.NET.V3 wrapper. (And the trouble with managing list segments isn’t the wrapper’s fault; it’s due to the way the MailChimp API itself is built.)

Videos: Using the MailChimp.NET.V3 wrapper library

Throughout this series I will be making videos on how to use the MailChimp.NET.V3 wrapper library.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Check out the Commenting Guidelines before commenting, please!
  • Want to share code? Please put it into a GitHub Gist, CodePen or pastebin and link to that in your comment.
  • Just have a line or two of markup? Wrap them in an appropriate SyntaxHighlighter Evolved shortcode for your programming language, please!