当前位置: 首页>>代码示例>>C#>>正文


C# MailChimpManager.BatchSubscribe方法代码示例

本文整理汇总了C#中MailChimpManager.BatchSubscribe方法的典型用法代码示例。如果您正苦于以下问题:C# MailChimpManager.BatchSubscribe方法的具体用法?C# MailChimpManager.BatchSubscribe怎么用?C# MailChimpManager.BatchSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MailChimpManager的用法示例。


在下文中一共展示了MailChimpManager.BatchSubscribe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BatchSubscribe_Successful

        public void BatchSubscribe_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();

            List<BatchEmailParameter> emails = new List<BatchEmailParameter>();

            BatchEmailParameter email1 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "[email protected]"
                }
            };

            BatchEmailParameter email2 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "[email protected]"
                }
            };

            emails.Add(email1);
            emails.Add(email2);

            //  Act
            BatchSubscribeResult results = mc.BatchSubscribe(lists.Data[1].Id, emails);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(results.AddCount == 2);
        }
开发者ID:RomeoQNgo,项目名称:MailChimp.NET,代码行数:34,代码来源:ListTests.cs

示例2: BatchSubscribe_Successful

        public void BatchSubscribe_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();

            List<BatchEmailParameter> emails = new List<BatchEmailParameter>();

            BatchEmailParameter email1 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "[email protected]"
                }
            };
						MergeVar mVar1 = new MergeVar();
						mVar1.Add("FNAME", "first1" + DateTime.Now);
						mVar1.Add("LNAME", "last1" + DateTime.Now);
						email1.MergeVars = mVar1;
						emails.Add(email1);

            BatchEmailParameter email2 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "[email protected]"
                }
            };
						MergeVar mVar2 = new MergeVar();
						mVar2.Add("FNAME", "first2" + DateTime.Now);
						mVar2.Add("LNAME", "last2" + DateTime.Now);
						email2.MergeVars = mVar2;
            emails.Add(email2);

            //  Act
            BatchSubscribeResult results = mc.BatchSubscribe(lists.Data[0].Id, emails);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(results.AddCount == 2);

						// load
						List<EmailParameter> emailsP = new List<EmailParameter>();
						emailsP.Add(email1.Email);
						MemberInfoResult memberInfo = mc.GetMemberInfo(lists.Data[0].Id, emailsP);
						Assert.AreEqual(mVar1["FNAME"], memberInfo.Data[0].MemberMergeInfo["FNAME"]);
						Assert.AreEqual(mVar1["LNAME"], memberInfo.Data[0].MemberMergeInfo["LNAME"]);

        }
开发者ID:erpframework,项目名称:MailChimp.NET,代码行数:49,代码来源:ListTests.cs

示例3: BatchSubscribe

        /// <summary>
        /// Batches the subscribe.
        /// </summary>
        /// <param name="recordList">The records</param>
        public virtual BatchSubscribeResult BatchSubscribe(IEnumerable<MailChimpEventQueueRecord> recordList)
        {
            if (string.IsNullOrEmpty(_mailChimpSettings.DefaultListId))
                throw new ArgumentException("MailChimp list is not specified");

            var mc = new MailChimpManager(_mailChimpSettings.ApiKey);
            var batchEmailParam = new List<BatchEmailParameter>();

            foreach (var sub in recordList)
            {
                try
                {
                    var emailParam = new EmailParameter
                    {
                        Email = sub.Email
                    };

                    var mergeVars = new MergeVar();

                    // TODO Customize your merge vars

                    // get customer and attributes
                    var customer = _customerService.GetCustomerByEmail(sub.Email);
                    if (customer != null)
                    {
                        AddAttribute(mergeVars, customer, SystemCustomerAttributeNames.FirstName, "FNAME");
                        AddAttribute(mergeVars, customer, SystemCustomerAttributeNames.LastName, "LNAME");
                        AddAttribute(mergeVars, customer, SystemCustomerAttributeNames.Phone, "PHONE");

                        var gender = customer.GetAttribute<string>(SystemCustomerAttributeNames.Gender);
                        switch (gender)
                        {
                            case "F":
                                mergeVars.Add("GENDER", "Mujer");
                                break;
                            case "M":
                                mergeVars.Add("GENDER", "Hombre");
                                break;
                            default:
                                mergeVars.Add("GENDER", "No especificado");
                                break;
                        }
                    }

                    //add to group
                    mergeVars.Groupings = new List<Grouping>() {new Grouping()};
                    mergeVars.Groupings[0].Name = "Yo soy";
                    mergeVars.Groupings[0].GroupNames = new List<string> { "Deportista" };

                    batchEmailParam.Add(new BatchEmailParameter()
                    {
                        Email = emailParam,
                        MergeVars = mergeVars
                    });
                }
                catch (Exception ex)
                {
                    _log.Warning(string.Format("Could not register email {0} to Mailchimp", sub.Email), ex);
                }
            }

            BatchSubscribeResult results = mc.BatchSubscribe(_mailChimpSettings.DefaultListId, batchEmailParam, true, true, false);
            return results;
        }
开发者ID:fcastells,项目名称:nopcommerce-mailchimp-plugin,代码行数:68,代码来源:MailChimpApiService.cs

示例4: Update

        public ActionResult Update(string id)
        {
            var defaultEvent = service.GetDefaultEvent();
            int eventid = defaultEvent.ID;
            MailChimpManager mc = new MailChimpManager(_mailchimpKey);
            ListInfo mailingList = mc.GetLists().Data.Where(l=>l.Id==id).SingleOrDefault();
            List<BatchEmailParameter> batchList = new List<BatchEmailParameter>();
            if (mailingList.Name.Contains("Speakers"))
            {
                foreach (var speaker in service.GetSpeakers(eventid))
                {
                    MyMergeVar myMergeVars = new MyMergeVar();
                    myMergeVars.FirstName = speaker.FirstName;
                    myMergeVars.LastName = speaker.LastName;           //  Create the email parameter
                    BatchEmailParameter batchEmail = new BatchEmailParameter();
                    EmailParameter email = new EmailParameter()
                    {
                        Email = speaker.Email

                    };
                    batchEmail.Email = email;
                    batchEmail.MergeVars = myMergeVars;

                    batchList.Add(batchEmail);
                }
            }
            if (mailingList.Name.Contains("Attendees"))
            {
                foreach (var attendee in service.GetAllAttendees(eventid))
                {
                    MyMergeVar myMergeVars = new MyMergeVar();
                    myMergeVars.FirstName = attendee.FirstName;
                    myMergeVars.LastName = attendee.LastName;           //  Create the email parameter
                    EmailParameter email = new EmailParameter()
                    {
                        Email = attendee.Email
                    };
                    BatchEmailParameter batchEmail = new BatchEmailParameter();
                    batchEmail.Email = email;
                    batchEmail.MergeVars = myMergeVars;

                    batchList.Add(batchEmail);

                }

            }
            BatchSubscribeResult bResult = mc.BatchSubscribe(id, batchList, false, true, true);
            //MyMergeVar myMergeVars = new MyMergeVar();
            //myMergeVars.FirstName = subscriber.FirstName;
            //myMergeVars.LastName = subscriber.LastName;           //  Create the email parameter
            //EmailParameter email = new EmailParameter()
            //{
            //    Email = subscriber.EmailAddress
            //};

            //EmailParameter results = mc.Subscribe(_mailchimpGroupId, email, myMergeVars);

            return RedirectToAction("Index");
        }
开发者ID:cfranciscodev,项目名称:WebSite,代码行数:59,代码来源:MailingListController.cs


注:本文中的MailChimpManager.BatchSubscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。