Code Monkey home page Code Monkey logo

mailchimp.net's Introduction

MailChimp.NET Build status deprecated

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

Note: This is for the 2.0 API (which is now deprecated). If you'd like a client for the 3.0 API, check out this one by Brandon Seydel

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:
MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");

// Next, make any API call you'd like:
ListResult lists = mc.GetLists();

Getting help

For help and support, first check out the examples below.

If you can't figure out what you need from the examples (or if you're running into a tough problem) you might want to check out the MailChimp support site, or ping the MailChimp API support twitter account.

If you've got a question/bug/feature request for the API wrapper itself, please use Github issues and consider contributing to the project yourself. See the "Making contributions" section for more information on how to contribute.

Examples

Getting the first 100 users in each list:
using MailChimp;
using MailChimp.Lists;
using MailChimp.Helper;

MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");
ListResult lists = mc.GetLists();

//  For each list
foreach(var list in lists.Data)
{
    //  Write out the list name:
	Debug.WriteLine("Users for the list " + list.Name);
	
	//  Get the first 100 members of each list:
	MembersResult results = mc.GetAllMembersForList(list.Id, "subscribed", 0, 100);
	
	//  Write out each member's email address:
	foreach(var member in results.Data)
	{
	    Debug.WriteLine(member.Email);
	}
}
Subscribe an email address to a list:
MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");

//	Create the email parameter
EmailParameter email = new EmailParameter()
{
	Email = "[email protected]"
};

EmailParameter results = mc.Subscribe("YourListID", email);
Subscribe an email address to a list and set their interest groups (custom merge variables):
// optionally create a class that inherits MergeVar and add any additional merge variable fields:
[System.Runtime.Serialization.DataContract]
public class MyMergeVar : MergeVar
{
	[System.Runtime.Serialization.DataMember(Name = "FNAME")]
	public string FirstName { get; set; }
	[System.Runtime.Serialization.DataMember(Name = "LNAME")]
	public string LastName { get; set; }
}

MyMergeVar myMergeVars = new MyMergeVar();
myMergeVars.Groupings = new List<Grouping>();
myMergeVars.Groupings.Add(new Grouping());
myMergeVars.Groupings[0].Id = 1234; // replace with your grouping id
myMergeVars.Groupings[0].GroupNames = new List<string>();
myMergeVars.Groupings[0].GroupNames.Add("Your Group Name");
myMergeVars.FirstName = "Testy";
myMergeVars.LastName = "Testerson";

MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");

//	Create the email parameter
EmailParameter email = new EmailParameter()
{
	Email = "customeremail@righthere.com"
};

EmailParameter results = mc.Subscribe("YourListID", email, myMergeVars);

// or use the Dictionary to specify the fields and values. 
// GetMemberInfo will always return the fields and values using the dictionary and not the custom class.
MergeVar myMergeVars = new MergeVar();
myMergeVars.Groupings = new List<Grouping>();
myMergeVars.Groupings.Add(new Grouping());
myMergeVars.Groupings[0].Id = 1234; // replace with your grouping id
myMergeVars.Groupings[0].GroupNames = new List<string>();
myMergeVars.Groupings[0].GroupNames.Add("Your Group Name");
myMergeVars.Add("FNAME", "Testy");
myMergeVars.Add("LNAME", "Testerson");

MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");

//	Create the email parameter
EmailParameter email = new EmailParameter()
{
	Email = "customeremail@righthere.com"
};

EmailParameter results = mc.Subscribe("YourListID", email, myMergeVars);
Getting location data for each list:
MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");
ListResult lists = mc.GetLists();

//  For each list
foreach(var list in lists.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(var location in locations)
	{
	    Debug.WriteLine("Country: {0} - {2} users, accounts for {1}% of list subscribers", location.Country, location.Percent, location.Total);
	}
}

Mocking

The IMailChimpManager and IMailChimpExportManager interfaces have been included to allow you to easily mock this API for your own testing.

To set up in your dependency injector, bind the interface with a constructor argument passing your API key. This example uses Ninject loading the value from an app setting in the Web.config named 'MailChimpApiKey':

kernel.Bind<IMailChimpManager>()
	.To<MailChimpManager>()
	.WithConstructorArgument("apiKey", ConfigurationManager.AppSettings["MailChimpApiKey"]);

If you were to use a framework like Moq you might write something like:

public class ThingThatDependsOnMailChimpManager{
	IMailChimpManager _mailChimpManager;

	public ThingThatDependsOnMailChimpManager(IMailChimpManager mailChimpManager){
		_mailChimpManager = mailChimpManager;
	}

	public bool DoSomething(){
		_mailChimpManager.UpdateCampaign("campaignId", "name", new object());
		return true;
	}
}
// Arrange
Mock<IMailChimpManager> mailChimpManagerMock = new Mock<IMailChimpManager>();

mailChimpManagerMock.Setup(x => x.UpdateCampaign(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<object>())
.Return(new CampaignUpdateResult());

// Act
var thing = new ThingThatDependsOnMailChimpManager(mailChimpManagerMock.Object);
var result = thing.DoSomething();

// Assert
Assert.IsTrue(result);

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% (85 of 120)

mailchimp.net's People

Contributors

adrianpell avatar andrewkoransky avatar ar7z1 avatar baconator avatar ballen avatar chrisofspades avatar codeclinic avatar ctolkien avatar danesparza avatar davidwalker avatar dazaris avatar ddtmm avatar deanhume avatar gdegroot avatar geoffreytran avatar joecar avatar leowin avatar lfagan avatar lxalln avatar mdissel avatar mikkoh85 avatar paulandrewcampbell avatar richard-west avatar roberttriggs avatar romeoqngo avatar sayten avatar tanapoln avatar vinneyk avatar will-weston avatar yagg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailchimp.net's Issues

GetReportUnsubscribed() is not deserializing reason_text

I've tested that in MakeAPICall with type Unsubscribes, the resultString includes a Unsubscribed member, with reason = OTHER and a reason_text = "some text".

But after -> results = resultString.Trim().FromJson();
the result for the member, have ReasonText = null

I then tried and renamed all "reason_text" to "reasontext" in the resultString and for the DataMember name in the UnsubscribesData class.
And that did the trick... now ReasonText have the string from the JSON resultString.

I have no idea for a solution other that making a renaming in the resultString.... not pretty :-(

This might be a problem in other areas to... I havent testet.

Using Templates

Hi Dan, this is more of a question rather than an issue, I tried to create a campaign using a template but I am unable to replace the editable content for the campaign, I can't see any options to do that, is this currently supported?

Updating Email Address with Custom MergVars Class

Has anyone tried doing this? The behaviour I'm seeing is that the NewEmail property is being ignored.

However if I use the standard MergVars class rather than a custom one inherited from MergVars, it seems to work!

I have even tried to add the DataMember attribute for "new-email" to a different property but still no joy.

Any ideas?

Thanks

Campaign Filter Fields Not Nullable

Hi, I had a look at the filters code and think there may be a problem with the two integer fields (FolderId and TemplateId) which default to 0, thus acting as a filter even if none is required. I tried setting both fields to string and the API accepted both and behaved as expected. Cheers, Steve

Can't use 'GROUPINGS' property of MemberMergeInfo

After retrieving member information from 'GetMemberInfo', 'MergeMembershipInfo' can have a property named 'GROUPINGS' which is described here. The problem is that it's only accessible as a string with all of its quotation marks removed, therefore it can't be parsed as JSON. Has anyone else run into this problem and solved it?

Merge Variables

Hi, do you plan to add support for custom merge variables? For example in GetMemberInfo() there is field merges.

Bug when unable to connect to server

ObjectNullReferenceException is thrown in MakeApiCall method in catch block when remote site is not available.

Problematic line is:

//  Throw a new exception based on this information:
throw new MailChimpAPIException(apiError.Error, ex, apiError);

but apiError is null.

Problem can be easily reproduced when you turn on firewall for outbound connections, so the remote site will be inaccessible.

nuGet DLL Strong Name: False

Downloaded the package via Package Manager Console. Referenced it in the Solution. It would not compile. Error caused by the DLL not having a Strong Name.

Used SN.EXE to generate a Public/Private Key. Then, followed a process found by Googling the error message. The process title was 'Sign a .NET Assembly with a Strong Name without Recompiling'.

It compiled but would not run due to another error...

Upgrading the project to use either .NET 4.0 or 4.5 framework

Would it be a breaking change if we updated this solution to use the .NET 4.0 or even 4.5 framework?

There are a few language enhancements that were introduced in .NET 4.0 that I would like to use in some refactoring of the MailChimpExport.cs class.

This is not a big deal either way, but it would be nice to take advantage of if the solution could be upgraded.

Multiple Campaign Filters Not Passed

One campaign filter passed outside of a collection container seems to work (though incorrectly - refer previous post) while one or more filter objects seems not to be deserialised by the API. So, whereas one filter sans collection container will return 0 campaigns, two identical filter objects in a collection container will return campaigns.

Add more fields when subscribing

I have a list in mailchimp wich has more fields than only email. I was wondering how I can send this fields to mailchimp using this api?

Thanks in advance.

ListFilter comment issue

The summary comments for ListFilter.Exact state that this defaults to true. I think it should say it defaults to false. Maybe I've misunderstood how it's supposed to work though.

    /// <summary>
    /// optional - flag for whether to filter on exact values when filtering, 
    /// or search within content for filter values - defaults to true
    /// </summary>

I.e., if I have the following three lines,

 string listName = "Test";
  ListFilter filter = new ListFilter();
  filter.ListName = listName;

The immediate window returns false for filter.Exact.

MergeVars on Members

Sorry to bug you again about that, but your class MemberInfo has a property MemberMergeInfo of your custom type MemberMergeInfo.
The problem is that MergeVars is a list variables defined by the account user

When you defined your custom MemberMergeInfo class you allow to read only standard fields, like EMIAL, FNAME, LNAME. The simplest solution is to use
Dictionary<string, string> for property MemberMergeInfo this way you allow to read all the fields (merge vars) for that list for that member. The only disadvantage of Dictionary<string, string&gt is that values are represented by string type, while at mailchimp you can define diffrent types than text. At the very end it's still better to get all value as string type than not to get all vaues :)

The difficult solution (and maybe not efficient) would be to first read data types by calling lists/merge-vars, and then fill the complex class, but thats too much, so for my use I'll just go with Dictionary<string, string>
untitled20140225135800

Project does not build

I get the following when building:

Error 1 The namespace 'MailChimp.Reports' already contains a definition for 'Industry' C:\Users\joec\Documents\GitHub\MailChimp.NET\MailChimp\Reports\Industry.cs 9 17 MailChimp

Also, TimeSeries does not appear to be defined.

nuget package: cannot update

Hi I have 1.0.0.6 installed and want to upgrade to 1.1.0.2 but the new 1.1.x depends on servicestack.text 3.9.71 (not minimum 3.9) and I have 4.0.17 installed. So I cannot upgrade to 1.1 because there is a newer version of servicestack.text and I cannot remove servicestack.text because mailchimp depends on it.
Can you change mailchimp that it requires at least 3.9 and not exactly? or can you use json.net instead of the serivcestack json? it is easier to upgrade.

How to get more than first 100 users in each list

I'm a bit rookie with using this wrapper, but how can I get more than first 100 users only? I have tried, for example, following:

results2 = mc.GetAllMembersForList(List.Id, "subscribed", 100, 100)

But it seems not to work. I have 113 users in my list. I am programming with Visual Basic, but any help is ok

Method not found: ServiceStack.....PostJsonToUrl

Greetings.
I am brand new to this API and I'm not positive if I am doing something wrong, or if this is a bug related to today's new release.

I used nuget to install the package.

i am attempted to run a few lines of sample code.

MailChimpManager mc = new MailChimpManager("MYKEY-REMOVED-FROM-POST");
ListResult lists = mc.GetLists();

I receive the following MissingMethodException

Method not found: 'System.String ServiceStack.Text.WebRequestExtensions.PostJsonToUrl(System.String, System.Object, System.Action1<System.Net.HttpWebRequest>, System.Action1<System.Net.HttpWebResponse>)'.

I attempted to update the ServiceStack package but it failed stating that the most current version was not compatible with MailChimp.Net.

I apologize if this is me making a mistake and not a bug,

Thanks!
Ross

Update ServiceStack.Text dependency?

Hi,

The current version depends ServiceStack.Text v.3.9.71 but I have other libraries that need a later version. Any chance of updating the dependency?

Naming suggestions for the Gallery methods

I'm implementing the gallery methods. The problem with these methods is that they contain the word Folder and there are already Folder methods implemented. To minimize confusion I would use the word Gallery in all methods. I'm open for other suggestions, here's what I came up with:

Already implemented

  • folders/add -> AddFolder
  • folders/del -> DeleteFolder
  • folders/list -> GetFolders
  • folders/update -> UpdateFolder

New methods

  • gallery/add-file-to-folder -> AddFileToGalleryFolder
  • gallery/add-folder -> AddGalleryFolder
  • gallery/list -> GetGalleries
  • gallery/list-folders -> GetGalleryFolders
  • gallery/remove-all-files-from-folder -> RemoveAllFilesFromGalleryFolder
  • gallery/remove-file-from-folder -> RemoveFileFromGalleryFolder
  • gallery/remove-folder -> RemoveGalleryFolder

Please create default instances for objects

Scenario: I create CampaignSegmentOptions

CampaignSegmentOptions x = new CampaignSegmentOptions();
x.Conditions.Add(some obj); //here I get null object error because Conditions is null

Here is the solution: a public constructor (I will add to my fork)

/// <summary>
/// A list of criteria on which to segment a list
/// </summary>
[DataContract]
public class CampaignSegmentOptions
{
    public CampaignSegmentOptions()
    {
        Conditions = new List<CampaignSegmentCriteria>();
    }

    /// <summary>
    /// Controls whether to use AND or OR when applying your options - expects "any" (for OR) or "all" (for AND)
    /// </summary>
    [DataMember(Name = "match")]
    public string Match { get; set; }
    /// <summary>
    /// Collection of up to 5 structs for different criteria to apply while segmenting. 
    /// Each criteria row must contain 3 keys - "field", "op", and "value" - and possibly a fourth, "extra", based on these definitions: http://apidocs.mailchimp.com/api/2.0/campaigns/segment-test.php
    /// </summary>
    [DataMember(Name = "conditions")]
    public List<CampaignSegmentCriteria> Conditions { get; set; }

}

missing MergeVar class

Please consider re-instatement of the deleted MergeVar class for utilization on the Lists.Subscribe method. Reasoning:

  • people who just want to use the API should have the most common fields available to them in this class... it also "self-documents" the lists/subscribe function, and makes it ready to use out of the box.

  • Interests/Groups are the recommended way to deal with multiple subscriber interests / mailings: http://kb.mailchimp.com/article/best-practices-for-lists#manage ("Maintain a single list per client or organization in your account.") So utilizing at least the grouping parameters is (or should be) very commonplace.

  • Assuming you re-instate the MergeVar class, here is an approach that works for adding additional fields to the merge_vars parameter:

    1. When you create your arguments object, cast the MergeVar type as an object so it properly gets serialized in the MailChimpManager.Subscribe:
            //  Create our arguments object:
            object args = new
            {
                apikey = this.APIKey,
                //...
                merge_vars = (object)mergeVars, 
                // cast to object so ServiceStack grabs the entire object 
                // (IE if it is inherited with custom merge fields added), 
                // not just the base type 
                //...
            };
  1. Then simply inherit the object and add the fields needed:
        [System.Runtime.Serialization.DataContract] 
        public class MyMergeVar : MergeVar
        {
            [System.Runtime.Serialization.DataMember(Name = "FNAME")]
            public string FirstName
            {
                get;
                set;
            }
            [System.Runtime.Serialization.DataMember(Name = "LNAME")]
            public string LastName
            {
                get;
                set;
            }
        }
  1. Then just pass an instance of your inherited class to Subscribe. It does work. I've tested it.

If you decide to implement, I would document the above capability somewhere. Heck, if you decide not to implement, please consider having a code example somewhere that shows a complete implementation using anonymous types too.

Thanks for your consideration. - Andrew

ServiceStack.Text version issue

Just got the latest NuGet package which installed ServiceStack.Text version 3.9.71.0 correctly.

When I run, though, I get this:

Foo : System.IO.FileNotFoundException : Could not load file or assembly 'ServiceStack.Text, Version=3.9.56.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

What needs to be done? Anything I can do on my end?

Importing lists or single contacts

Is there any way to import contacts to list instead of using subscribe method? Advantage would be that it wouldn't send subscription email to all people. I could not find such method from MailChimp API 2.0, so I suppose it is not possible. You got any solutions to this?

Call Subscribe method returns exception if email already exists

I have installed MailChimp.NET 1.1.34 from NuGet, but when I call the Subscribe method and the email already exists in the list it returns an exception that the email already exists. Shouldn't it just update the email (+ additonal fields) based on the value of updateExisting parameter?

Right now if call only the method, if the email doesn't exists:

MailChimpManager mc = new MailChimpManager(api_key);
ListResult lists = mc.GetLists();
string listId = list_key;

//  Create the email parameter
EmailParameter emailParam = new EmailParameter()
{
       Email = email
};

//  Check if the email already exists
Matches match = mc.SearchMembers(emailParam.Email, list_key);
EmailParameter ep = new EmailParameter();

MailChimpResponse response = new MailChimpResponse();

if (match.ExactMatches.Members.Count > 0)
{
         // already subscribed
         ep.Email = emailParam.Email;
         response.emailExists = true;
         //Response.Write("You are already subscribed");
}
else
{
         // subscribe
         ep = mc.Subscribe(listId, emailParam, null, "html", false, false, true, false);
         response.emailExists = false;
         //Response.Write("You are now subscribed");
}
response.emailParameter = ep;
return JsonConvert.SerializeObject(response);

ListInfo.ListStats

ListInfo.ListStats doesn't seem to correspond with the response from mailChimp api [http://apidocs.mailchimp.com/api/2.0/lists/list.php].

For example date_last_campaign isn't in the documentation at all (and probably should be string not int), and all of the numeric values are doubles not ints. Some logicially should be ints like GroupCount, but ClickRate,OpenRate,TargetSubRate,AvgUnsubRate,AvgSubRate all come in as doubles and turn to 0 when serialized by the api.

how to view errors returned from Mailchimp?

hi
given your code sample below for "Subscribing" an email, if there were mailchimp errors for any reason how to you see what these are? thanks

MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");

// Create the email parameter
EmailParameter email = new EmailParameter()
{
Email = "[email protected]"
};

EmailParameter results = mc.Subscribe("YourListID", email);

Optimize 'using' directives

Please consider optimizing the 'using' directives, especially the reference to "System.Threading.Tasks" makes it impossible to build the project with .NET 3.5.

Why you don't use enums?

For example a method GetAllMembersForList, the second optional field is raw string from mailchimp "subscribed" / "unsubscribed".

It would be better for use of API to have an enum like

public enum MemberStatus
{
Subscribed,
Unsubscribed
}

Then all you need to do is to translate to proper MC equivalent or in given example call ToString().ToLower();

Generally would be much easier to work with C# enums than with strings, otherwise consumers of the API wrapper need to come up with own solutions... and continously check MC documentation for flags and enumerations that in my opinion should be included in API wrapper as fully navigable code...

(I know, I should fork it, but since it's your baby, just an advice ;))

using MergeVar to update FNAME, LNAME etc

Can you give an example of how to use your MergeVar class to update FNAME etc...
I just can't see how it can be done at the moment. (of course i could be being blind!!!)
Thanks

How do you get click data per member from campaign?

Hi, this is just a question. I am trying to get the campaign click detail (as in Reports/Click-Detail) but I cannot find an easy way of doing this without using GetMemberActivity. Is the Click-Detail implemented anywhere or is there a different way of getting campaign related click data for members?

error in Export Api to fetch list method ()

I am thinking of using Export API to get a list of members from a list id who subscribed or modified in last week but how to access this list method as I install mailchimp from nuGet. (https://www.nuget.org/packages/MailChimp.NET/)
(used wrapper coded by you)

and now when i try to use

MailChimpManager mc = new MailChimpManager(MC_APIKey);

and now when i try to access list() from mc.list() i can';t see this method .

So i thought i need to add reference again with (http://us4.api.mailchimp.com/export/1.0/) as my api contains us4.

when i try to add reference with this link i get error
(There was an error downloading 'http://us4.api.mailchimp.com/export/1.0/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://us4.api.mailchimp.com/export/1.0/'.
There was no endpoint listening at http://us4.api.mailchimp.com/export/1.0/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.)

NullRefere​nceExcepti​on in the MailChimpM​anager GetListsFo​rEmail method

I've runinto a problem using the GetListsForEmail method to determine which Lists an email is associated with and wondered if you could help me out.

Using the example code in the Tests project I am calling the method as follows

MailChimpManager mc = new MailChimpManager(myAPIKey);

List<ListForEmail> details = mc.GetListsForEmail(new EmailParameter()
{
    Email = "[email protected]"
});

If I pass an email address which is not a member of any list in the account associated with myAPIKey, an Email_NotExists error is returned as expected.

However, if I pass an email address which is a member of a list in the account, then I get a NullReferenceException with the following stack trace

[NullReferenceException: Object reference not set to an instance of an object.]     MailChimp.MailChimpManager.MakeAPICall(String apiAction, Object args) +321 MailChimp.MailChimpManager.GetListsForEmail(EmailParameter emailParam) +119 WebApplication1.Default.GetMemberSubscriptionsButton_Click(Object sender, EventArgs e) in c:\Projects\Test\WebApplication1\Default.aspx.cs:99 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553178 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103             System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Any idea what I am doing wrong?

Which IDE (version) to use?

Hi,

I'm trying to build for the DLL. However, if I download the zip file or fork the repository, I can't open the project file in Visual Studio 2010, due to the error message of 'the selected file is a solution file, but was created by a newer version of this application and cannot be opened'.

Before I needlessly upgrade, or upgrade to a wrong version/IDE, which IDE (version) does one need to build the DLL?

Thanks for any insights,

Campaigns / CampaignTypeAutoResponderOptions repeated field

    /// <summary>
    ///The hour of the day - 24 hour format in GMT - the autoresponder should be triggered, ignored for "hourly"
    /// </summary>
    [DataMember(Name = "schedule_hour")]
    public string ScheduledHour
    {
        get;
        set;
    }
    /// <summary>
    ///whether or not imported subscribers (ie, any non-double optin subscribers) will receive
    /// </summary>
    [DataMember(Name = "schedule_hour")]
    public bool UseImportTime
    {
        get;
        set;
    }

ETA to have a newer version of the NuGet package?

Hi,

I need to have the UpdateMember API and I see that it has been implement in the source code but does not have been published on NuGet.

Before changing my projects to use my compiled version of the code, I was wondering if there was any plans to have an updated version on NuGet.

Thank you, keep up the good work! :)

Will MailChimp.NET compile in .NET 3.5?

When I tried to install the NuGet package, I got the following error:

Could not install package 'MailChimp.NET 1.1.0.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references or content files that are compatible with that framework.

How to add automatically an email to a group?

How to add automatically an email to a group?
I've tryed with MergeVars

var group = new Grouping()
{
Name = "Male",
GroupNames=new List(){"Gender"}
};

var merge_var = new CustomMergeVars
{
...
Groupings = new List() { group }
};

but i get this error

"0" is not a valid Interest Grouping id for the list: "list_name"

Thanks

Dependency of ServiceStack.Text v3.9.71

After updating the ServiceStack.Text library (via automatic NuGet updates) the MailChimp API throws a runtime TypeLoadException.

It occures since i updated to ServiceStack.Text v4.0.11 and says:

Could not load type 'ServiceStack.Text.WebRequestExtensions' from assembly 'ServiceStack.Text, Version=4.0.11.0, Culture=neutral, PublicKeyToken=null'.

[TypeLoadException: Could not load type 'ServiceStack.Text.WebRequestExtensions' from assembly 'ServiceStack.Text, Version=4.0.11.0, Culture=neutral, PublicKeyToken=null'.]
   MailChimp.MailChimpManager.MakeAPICall(String apiAction, Object args) +0
   .... (my namespaces)

As far as i figured out they removed this Exception type from this namespace. I think you should modify the nuget package depency of the MailChimp API package so that it does not allow the latest versions of ServiceStack.Text...? Or just update the MailChimp API so that it is compatible with the latest ServiceStack.Text updates!

How to add Google Analytics in API

This is my attempt, but I get an error from Mailchimp that I can't source why.

CampaignCreateOptions options = new CampaignCreateOptions();
GoogleURL = "utm_source=" + GA_Source;
GoogleURL += "&utm_medium=" + GA_Medium;
GoogleURL += "&utm_campaign=" + GA_Name;
CampaignAnalyticsOptions GoogleAnalytics = new CampaignAnalyticsOptions();
GoogleAnalytics.Google = GoogleURL;
options.Analytics = GoogleAnalytics;

Issue with System.IO.FileNotFoundException: Filen eller assemblyen 'ServiceStack.Text, Version=3.9.71.0

I am using Umbraco /base and have installed MailChimp.NET 1.1.34 from NuGet. But when I call the url (which would be like this: http://www.mydomain.com/base/MailchimpNewsletter/SubscribeMail/{email}.aspx through a clean Umbraco install it returns something like this:

<error><![CDATA[MESSAGE:
Destinationen for en aktivering udløste en undtagelse.

STACKTRACE:
   ved System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   ved System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   ved System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   ved Umbraco.Web.BaseRest.RestExtensionMethodInfo.Invoke(String[] parameters)

INNEREXCEPTION:
System.IO.FileNotFoundException: Filen eller assemblyen 'ServiceStack.Text, Version=3.9.71.0, Culture=neutral, PublicKeyToken=null' eller en af dens afhængigheder kunne ikke indlæses. Den angivne fil blev ikke fundet.
Filnavn: 'ServiceStack.Text, Version=3.9.71.0, Culture=neutral, PublicKeyToken=null'
   ved MailChimp.MailChimpManager..ctor()
   ved MailChimp.MailChimpManager..ctor(String apiKey)
   ved UmbracoAjaxSubscribeForm.Library.MailchimpSubscription.SubscribeMail(String email) i c:\Users\Bjarne\Documents\Visual Studio 2013\Projects\MailChimp.NET_example\MailChimp.NET_example\Library\MailchimpSubscription.cs:linje 38

WRN: Logføring af assemblybinding er deaktiveret.
Logføring af assemblybindingsfejl aktiveres ved at angive registreringsdatabaseværdien [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) til 1.
Bemærk! Ydeevnen forringes ved logføring af assemblybindingsfejl.
Denne funktion deaktiveres ved at fjerne registreringsdatabaseværdien [HKLM\Software\Microsoft\Fusion!EnableLog].
]]></error>

Maybe it's something related or simular to this issue:
#48

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization;
using Umbraco.Web.BaseRest;
using MailChimp;
using MailChimp.Helper;
using MailChimp.Lists;
using Newtonsoft.Json;
//using ServiceStack.Text;

namespace UmbracoAjaxSubscribeForm.Library
{
    [RestExtension("MailchimpNewsletter")]
    public class MailchimpSubscription
    {
        private enum status { SUCCESS, ERROR };
        private static string api_key = System.Web.Configuration.WebConfigurationManager.AppSettings["MailChimp:apiKey"];
        private static string list_key = System.Web.Configuration.WebConfigurationManager.AppSettings["MailChimp:listKey"];

        [RestExtensionMethod(ReturnXml = false, AllowAll = true)]
        public static string SubscribeMail(string email)
        {
            if (!string.IsNullOrEmpty(email) && checkEmail(email))
            {
                MailChimpManager mc = new MailChimpManager(api_key);
                ListResult lists = mc.GetLists();
                string listId = list_key; //lists.Data[0].Id;

                //  Create the email parameter
                EmailParameter emailParam = new EmailParameter()
                {
                    Email = email
                };

                //  Check if the email already exists
                Matches match = mc.SearchMembers(emailParam.Email, list_key); //lists.Data[0].Id
                EmailParameter ep = new EmailParameter();

                MailChimpResponse response = new MailChimpResponse();

                if (match.ExactMatches.Members.Count > 0)
                {
                    // already subscribed       
                    ep.Email = emailParam.Email;
                    response.emailExists = true;
                    //Response.Write("You are already subscribed");
                }
                else
                {
                    // subscribe
                    ep = mc.Subscribe(listId, emailParam, null, "html", false, false, true, false);
                    response.emailExists = false;
                    //Response.Write("You are now subscribed");
                }
                response.emailParameter = ep;
                return JsonConvert.SerializeObject(response);
            }
            else
            {
                return "";
            }
        }

        private static bool checkEmail(string email)
        {
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            System.Text.RegularExpressions.Match match = regex.Match(email);
            return match.Success;
        }

        public class MailChimpResponse
        {
            public EmailParameter emailParameter { get; set; }
            public bool emailExists { get; set; }
        }
    }
}

but if I then include using ServiceStack.Text; and rebuild the project, copy the compiled assembly + the compiled ServiceStack.Text.dll to my Umbraco installation, then it just fine return the exspected json like this:

{
emailParameter: {
    email: "[email protected]",
    euid: "xxxxxxxxxxxx",
    leid: "xxxxxxxxxxxx"
},
emailExists: false
}

where xxxxxxxxxxxx of course is the right id's ... or if the email already exists in the list:

{
emailParameter: {
    email: "[email protected]",
    euid: null,
    leid: null
},
emailExists: true
}

as I get an exception when calling the Subscribe method when email already exists in the list #99, I just create a new instanse of EmalParameter and set the email + adding a bool with value true.

Is the issue with ServiceStack.Text an issue with the NuGet package? It shouldn't be necessary to include that reference?

Since parameter

Right now I'm doing feature to sync latest added / updated members from MailChimp to our SQL database. I searched MailChimp API and found this:

http://apidocs.mailchimp.com/api/1.3/listmembers.func.php

There is this since parameter, which filters only members changed or created since given date/time. I would need this to add members modified after last sync. Is there any way to use this in this Wrapper?

That feature seems to be in MC API v1.3, so does it even exist anymore? This same thing can be done with Export API, but I suppose this wrapper doesn't support it?

Any help?

Missing MergeVar

MergeVar Class is missing from the last build. Can you help please?

Please Add default constructor to EmailParameter

Would be much easier to work with API if there would be at lest one constructor for email

[DataContract]
public class EmailParameter
{
       /* new code starts here */
       public EmailParameter() //this for serialization
      {
      }

      public EmailParameter(string emailAddress)
      {
          Email = emailAddress;
      }
      /* new code ends here */

...
}

MailChimp.Lists.MemberInfo.MemberMergeInfo changed!

I can see that you have changed the MemberMergeInfo from a Dic of strings, to MergeVar

That might be okay when creating MyMergeVar : MergeVar, that I would use when subscribing members with BatchEmailParameter.

But when I call GetAllMembersForList() or GetMemberInfo() it cannot deserialize the list of MergeVars "merges" that comes from MailChimp to a MergeVar object.

Have you missed something here, or do I need to do something different?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.