Create Campaign

Mar 1, 2011 at 6:46 PM

Hi,

I am trying to create a campaign using the api but I am facing some problems setting the Content object:

MCApi api = new MCApi(_apikey, false);
var option = new Campaign.Options(_list_id, "Subject", "mail@mail.com", "FromName", "ToName");
// Using a template
option.TemplateID = new FSharpOption<int>(121212);
        
var content = new Campaign.Content();
// According to the api documentation:
//If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a //template. Supported template sections include: "html_HEADER", "html_MAIN", "html_SIDECOLUMN", and "html_FOOTER

// How can I set the following to the content property??

            //content = new Dictionary<string, string>
            //                  {
            //                      {
            //                          "html_MAIN",
            //                          "Headling"
            //                          }
            //                  };

string cid = api.CampaignCreate(Campaign.Type.Regular, option, content);

Hoping for help :-)

Thanks

Coordinator
Mar 2, 2011 at 12:46 PM

Totally missed this point :(

I changed the whole structure of campaign content (Look at the last change set). 

So now you can use this:

 


 

var api = new MCApi(_apikey, false);

var option = new Campaign.Options(_list_id, "Subject", "mail@mail.com", "FromName", "ToName");

option.TemplateID = new FSharpOption<int>(121212);

 

var content = new Campaign.Content.Template();  // Other options are: base, html and archive

content.Header = "blah-blah-header";

content.Main = "blah-blah-main";

...

content.Text = "blah-blah-text"

 

string cid = api.CampaignCreate(Campaign.Type.Regular, option, content);

 


 

P.S. May be this should be implemented as simple dictionary?

Mar 2, 2011 at 4:43 PM

Super! It just works.

Thanks for a quick reply.

Best regards,

Anders