Skip to content

Instantly share code, notes, and snippets.

@shahriarhossain
Last active January 27, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahriarhossain/3f0076fb7a16d1672fae to your computer and use it in GitHub Desktop.
Save shahriarhossain/3f0076fb7a16d1672fae to your computer and use it in GitHub Desktop.
MailChimpCampaigns campaign = new MailChimpCampaigns();
Recipients recipients = new Recipients()
{
list_id = "0a84a63afc" //Put your list id
};
Settings campaignSettings = new Settings()
{
subject_line = "Write down your subject line ",
title = "We are Ready !!!!",
from_name = "Shahriar Hossain",
reply_to = "shossain@desme.com",
template_id = 18073, //Put your template id that you want to use
authenticate = true,
auto_footer = false
};
Tracking campaignTracking = new Tracking()
{
opens = true,
html_clicks = true,
text_clicks = true
};
ResultWrapper<Campaign> campaignCreationResult = campaign.CreateCampaignAsync(CampaignType.regular, recipients, campaignSettings, campaignTracking).Result;
if (campaignCreationResult.HasError == false)
{
///Upload email template
ContentSetting cSetting = new ContentSetting();
string path = @"file_directory\fileName_with_extension";
FileParser parser = new FileParser();
cSetting.html = parser.EmailParser(path);
var setContentStatus = campaign.SetCampaignContentAsync(campaignCreationResult.Result.id, cSetting).Result;
///Alternatively you can Set template as well
//ContentTemplate template = new ContentTemplate()
//{
// id = "18073" //Put your template id that you want to use
//};
//var setContentStatus = campaign.SetCampaignContentAsync(campaignCreationResult.Result.id, template).Result;
var checkListResult = campaign.GetCampaignContentAsync(campaignCreationResult.Result.id).Result;
if (checkListResult.is_ready)
{
var sendStatus = campaign.SendCampaignAsync(campaignCreationResult.Result.id).Result;
}
}
else
{
String.Format("Best of Luck! I can't handle :p");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment