I need to create and send campaigns right away MailChimp.com. For this purpose I used . C# wrapper Percepective MCAPI.dll
from the MailChimp API , it’s clear that we cannot write off, but we can create campaigns. I tried the code, but campaignID is retured null; No exception is thrown at least. I have installed campaigntype to Auto.
here is my code snippet:
try
{
string apiKey = "api-us2"; // API KEY is valid
string emailAddress = " ravinderpal.singh@abc.net ";
listsForEmailInput lstForEmailInput = new listsForEmailInput (apiKey, emailAddress);
listsForEmail cmd = new listsForEmail (lstForEmailInput);
listsForEmailOutput lstEmailOutPut = cmd.Execute ();
List lstResults = lstEmailOutPut.result;
string listID = lstResults [0]; // Got Precraeted List ID (Valid Confirmed)
Console.WriteLine ("\ n" + listID);
// compaign Create
campaignCreateOptions campaignCreateOpt = new campaignCreateOptions ();
campaignCreateOpt.list_id = listID;
campaignCreateOpt.subject = "New Campaign from dev_Anil";
campaignCreateOpt.from_email = " anil.k@abc.net ";
campaignCreateOpt.from_name = "anil";
Dictionary content = new Dictionary ();
content.Add ("html", "Helloaasdsa");
content.Add ("text", "Hi all !! this is dev_anil");
content.Add ("url", "");
content.Add ("archive", "");
campaignSegmentOptions csOptions = new campaignSegmentOptions ();
csOptions.match = "any"; // Could not set Condition - need help for this
// Need to set a Dictionary typeOptions because null is not supported
Dictionary typeOptions = new Dictionary ();
campaignCreateParms campaignCreateParms = new campaignCreateParms (apiKey, EnumValues.campaign_type.auto, campaignCreateOpt, content, csOptions, typeOptions);
campaignCreateInput campaignCreateInput = new campaignCreateInput (campaignCreateParms);
campaignCreate campaignCreate = new campaignCreate (campaignCreateInput);
campaignCreateOutput ccOutput = campaignCreate.Execute (campaignCreateInput);
string abc = ccOutput.result; // This comes out to null
}
catch (Exception ee)
{
Console.WriteLine ("\ n \ n Exception:" + ee.Message); // no exception
}
Can someone show me the right direction and what is wrong with the code.
any help would be greatly appreciated.
thank.
source
share