Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6470635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:08:01+00:00 2026-05-25T06:08:01+00:00

I need to create and send immediately campaigns in MailChimp.com . I used C#

  • 0

I need to create and send immediately campaigns in MailChimp.com. I used C# wrapper Percepective MCAPI.dll for this purpose.

from the MailChimp API, Its clear that we cannot lists but can create campaigns. I tried code but the campaignID is retured null; no exception thrown atleast. I did set the 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 anybody show me the right direction and what is wrong with the code.

any help would be much appreciated.

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:08:02+00:00Added an answer on May 25, 2026 at 6:08 am

    I solved this problem and here is code as solution. here listID is precreated List ID in your account in Mailchimp.

    private void CreateCampaignAndSend(string apiKey, string listID)
    {
                Int32 TemplateID = 100;
                string campaignID =string.Empty;

    // compaign Create Options
    campaignCreateOptions campaignCreateOpt = new campaignCreateOptions();
    campaignCreateOpt.list_id = listID;
    campaignCreateOpt.subject = "subject";
    campaignCreateOpt.from_email = "abc@xyz.com";
    campaignCreateOpt.from_name = "abc";
    campaignCreateOpt.template_id = TemplateID;

    // Content

    Dictionary<string, string> content = new Dictionary<string, string>();
    content.Add("html_ArticleTitle1", "ArticleTitle1");
    content.Add("html_ArticleTitle2","ArticleTitle2");
    content.Add("html_ArticleTitle3", "ArticleTitle3");
    content.Add("html_Article1", "Article1");
    content.Add("html_Article2", "Article2");

    // Conditions
    List<campaignSegmentCondition> csCondition = new List<campaignSegmentCondition>();
    campaignSegmentCondition csC = new campaignSegmentCondition();

    csC.field = "interests-" + 123; // where 123 is the Grouping Id from listInterestGroupings()
    csC.op = "all";
    csC.value = "";
    csCondition.Add(csC);

    // Options
    campaignSegmentOptions csOptions = new campaignSegmentOptions();
    csOptions.match = "all";

    // Type Options
    Dictionary<string, string> typeOptions = new Dictionary<string, string>();
    typeOptions.Add("offset-units", "days");
    typeOptions.Add("offset-time", "0");
    typeOptions.Add("offset-dir", "after");

    // Create Campaigns

    campaignCreate campaignCreate = new campaignCreate(new campaignCreateInput(apiKey, EnumValues.campaign_type.plaintext, campaignCreateOpt, content, csOptions, typeOptions));
    campaignCreateOutput ccOutput = campaignCreate.Execute();

    List<Api_Error> error = ccOutput.api_ErrorMessages; // Catching API Errors

    if (error.Count <= 0)
    {
    campaignID = ccOutput.result;

    }
    else
    {
    foreach (Api_Error ae in error)
    {
    Console.WriteLine("\n ERROR Creating Campaign : ERRORCODE\t:" + ae.code + "\t ERROR\t:" + ae.error);

    }
    }

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create Client/Server application to send files from clients to Server. I
I need to create a keyed hash for a string of XML to send
I need to create a historical timeline starting from 1600's to the present day.
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a distributed application consisting of multiple clients that send files
I need to create xml message and send it to the web service. Then
To send data to a file on my FTP server, I need to create
I need to send a soap-request that looks like this: <v:Envelope xmlns:i=http://www.w3.org/2001/XMLSchema-instance xmlns:v=http://schemas.xmlsoap.org/soap/envelope/> <v:Header/>
I need to create web service (.NET) which will be used by other system.
I am a bit confused on how i create and send this call to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.