Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate MailChimp in C#/.Net

Tags:

I want to send email through MailChimp. How to do this in .Net?

Does any one have sample code?

Thanks.

like image 672
Waheed Avatar asked Apr 27 '11 10:04

Waheed


People also ask

How does Mailchimp integration work?

Some integrations automatically sync events you manage with an external app or platform to your Mailchimp account. New events will continue to sync automatically until you disconnect the integration. Once you have the data in Mailchimp, you can use it to send custom messaging to your contacts.

Does Mailchimp work with Office 365?

Mailchimp + Microsoft Office 365 IntegrationsZapier lets you send info between Mailchimp and Microsoft Office 365 automatically—no code required. Triggers when a recipient opens an e-mail in a specific campaign.


1 Answers

The example below will send a opt-in email:

First install the NuGet package: Install-Package mcapi.net

    static void Main(string[] args)     {         const string apiKey = "6ea5e2e61844608937376d514-us2";   // Replace it before         const string listId = "y657cb2495";                      // Replace it before          var options = new List.SubscribeOptions();         options.DoubleOptIn = true;         options.EmailType = List.EmailType.Html;         options.SendWelcome = false;          var mergeText = new List.Merges("[email protected]", List.EmailType.Text)                     {                         {"FNAME", "John"},                         {"LNAME", "Smith"}                     };         var merges = new List<List.Merges> { mergeText };          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();     } 
like image 117
Fernando Vezzali Avatar answered Oct 25 '22 03:10

Fernando Vezzali