Exemplo n.º 1
0
 public void CampaignSegmentTest_Successful()
 {
     //  Arrange
     MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
     ListResult lists = mc.GetLists();
     CampaignSegmentOptions options = new CampaignSegmentOptions();
     options.Match= "All";
     string dateListCreated = lists.Data[1].DateCreated;
     List<CampaignSegmentCriteria> conditions = new List<CampaignSegmentCriteria>();
     conditions.Add(new CampaignSegmentCriteria { Field = "date", Operator = "eq", Value = dateListCreated });
     options.Conditions = conditions;
     string listId = lists.Data[1].Id;
     //  Act
     CampaignSegmentTestResult result = mc.CampaignSegmentTest(listId,options);          
     //  Assert
     Assert.IsTrue(result.Total == 1);
 }
		/// <summary>
		/// Exports/dumps members of a list and all of their associated details. 
		/// This is a very similar to exporting via the web interface.
		/// </summary>
		/// <param name="listId">the list id to connect to (can be gathered using GetLists())</param>
		/// <param name="status">optional - the status to get members for - one of(subscribed, unsubscribed, cleaned)</param>
		/// <param name="segment">refine the members list by segments (maximum of 5 conditions)</param>
		/// <param name="since">only return member whose data has changed since a GMT timestamp – in YYYY-MM-DD HH:mm:ss format</param>
		/// <param name="hashed"> if, instead of full list data, you'd prefer a hashed list of email addresses, set this to the hashing algorithm you expect. Currently only "sha256" is supported. NOT IN USE NOW</param>        
		/// <returns></returns>
		public List<Dictionary<string, string>> GetAllMembersForList(string listId, string status = "subscribed", CampaignSegmentOptions segment = null, string since = "1900-01-01 00:00:00", string hashed = "")
		//int start = 0, int limit = 25, string sort_field = "", string sort_dir = "ASC", CampaignSegmentOptions segment = null)
		{
			//  Our api action:
			string apiAction = "list";

			//  Create our arguments object:
			object args = new
			{
				apikey = this.APIKey,
				id = listId,
				status = status,
				//segment = segment,
				since = since,
				//hashed = hashed
			};

			//  Make the call:
			return MakeExportAPICall(apiAction, args);
		}
Exemplo n.º 3
0
        public void CampaignCreate_Successful()
        {
            // Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            string listID = lists.Data[1].Id;
            CampaignSegmentOptions segmentOptions = new CampaignSegmentOptions();
            segmentOptions.Match = "All";
            string dateListCreated = lists.Data[1].DateCreated;
            segmentOptions.Conditions = new List<CampaignSegmentCriteria>();
            segmentOptions.Conditions.Add(new CampaignSegmentCriteria { Field = "date", Operator = "eq", Value = dateListCreated });
            CampaignCreateContent content = new CampaignCreateContent();
            content.HTML = "<p>Testing</p>";
            CampaignCreateOptions options = new CampaignCreateOptions();
            options.Title = "Testing";
            options.ListId = listID;
            options.ToName = "Test Name";
            options.FromEmail = "*****@*****.**";
            options.FromName = "Testing Company Name";
            options.Subject = "Test Subject";

            //Act
            Campaign result = mc.CreateCampaign("regular", options, content, segmentOptions, null);
            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 4
0
        private static void CreateCampaign()
        {
            // Arrange
            MailChimpManager mc = new MailChimpManager("e20533551f21cbc6b07c76e570dc33c4-us11");
            //ListResult lists = mc.GetLists();
            //string listID = lists.Data[0].Id;
            CampaignSegmentOptions segmentOptions = new CampaignSegmentOptions();
            segmentOptions.Match = "All";
            //string dateListCreated = lists.Data[0].DateCreated;
            segmentOptions.Conditions = new List<CampaignSegmentCriteria>();
            segmentOptions.Conditions.Add(new CampaignSegmentCriteria { Field = "date", Operator = "eq"});
            CampaignCreateContent content = new CampaignCreateContent();
            content.HTML = @"
            <meta charset='utf-8'>
            <title></title>

            <table width='600' border='0' align='center' cellpadding='0' cellspacing='0' style='background-color: #f0eeee; padding: 20px;'>
            <tbody><tr>
            <td>
                <table width='600' border='0' align='center' cellpadding='0' cellspacing='0'>
                    <tbody><tr>
                        <td style='background-color: #ffa900; padding: 10px 30px;'>
                            <img src='http://*****:*****@desme.com";
            options.FromName = "Testing Company Name";
            options.Subject = "Email template testing";
            Campaign result = mc.CreateCampaign("regular", options, content);
        }
Exemplo n.º 5
0
        public void CampaignSavedSegmentTest_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            Assert.IsNotNull(lists);
            Assert.IsTrue(lists.Data.Count > 0);
            string listID = lists.Data[1].Id;
            CampaignSegmentOptions options = new CampaignSegmentOptions();
            options.SavedSegmentId = "yourSavedSegmentId";

            //  Act
            CampaignSegmentTestResult result = mc.CampaignSegmentTest(listID, options);
            
            //  Assert
            Assert.IsTrue(result.Total > 0);
        }
        public void SendCampaign()
        {
            if ((cmbTemplate.SelectedIndex > 0 && cmbTemplate.SelectedItem != null) && (cmbList.SelectedIndex > 0 && cmbList.SelectedItem != null))
            {
                Int32 selectedTemplateId = Convert.ToInt32(cmbTemplate.SelectedValue);

                string selectedListId = cmbList.SelectedValue.ToString();
                //IEnumerable<string> listEnum = new string[] { selectedListId.ToString() };

                //--Create Campaign
                CampaignSegmentOptions segmentOptions = new CampaignSegmentOptions();
                segmentOptions.Match = "All";
                CampaignCreateOptions options = new CampaignCreateOptions();
                options.Title = mailchimptitle;
                options.ListId = selectedListId;
                options.ToName = mailchimpToName;
                options.FromEmail = mailchimpFromEmail;
                options.FromName = mailchimpFromName;
                options.Subject = mailchimpSubject;
                options.TemplateID = selectedTemplateId;
                CampaignCreateContent content = new CampaignCreateContent();
                Campaign result = mc.CreateCampaign("regular", options, content, null, null);


                //GetMemberInfo
                if (chkEnableSMS.Checked)
                {
                    List<EmailParameter> emails = new List<EmailParameter>();
                    MembersResult results = mc.GetAllMembersForList(selectedListId, "subscribed", 0, 100);
                    foreach (var i in results.Data)
                    {
                        foreach (var j in i.MemberMergeInfo)
                        {
                            if (j.Key.Trim() == "PHONE")
                            {
                                if (!string.IsNullOrEmpty(j.Value.ToString()))
                                {
                                    //  SmsSender.SendSMS(j.Value.ToString(), "919460264151", "5b2a23d7", "59d9fa03", Uri.EscapeUriString("Test Message"));
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("Success");
            this.Close();
        }