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


C# MailChimpManager.Subscribe方法代码示例

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


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

示例1: Send

        public void Send(String idUser, String firstName, String email)
        {
            String emailAPI = ConfigurationManager.AppSettings["MailChimpAPI"].ToString();

            MailChimpManager mc = new MailChimpManager(emailAPI);

            ListResult lists = mc.GetLists();

            EmailConfirm emailConfirm = new EmailConfirm();
            //emailConfirm.Groupings = new List<Grouping>();
            //emailConfirm.Groupings.Add(new Grouping());
            //emailConfirm.Groupings[0].Id = 1234; // replace with your grouping id
            //emailConfirm.Groupings[0].GroupNames = new List<string>();
            //emailConfirm.Groupings[0].GroupNames.Add("Your Group Name");
            emailConfirm.FirstName = firstName;
            emailConfirm.IdUser = idUser;

            //  Create the email parameter
            EmailParameter parameters = new EmailParameter()
            {
                Email = email
            };

            //            ListResult lr = mc.GetLists();
            EmailParameter results = mc.Subscribe("d31fd680be", parameters, emailConfirm);
        }
开发者ID:NannyWeb,项目名称:Nanny,代码行数:26,代码来源:EmailHelper.cs

示例2: Post

        // POST api/mailchimp
        public string Post(Subscriber subscriber)
        {
            MailChimpManager mc = new MailChimpManager(_mailchimpKey);
            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 results.LEId;
        }
开发者ID:BryanTheWeary,项目名称:ONETUG-web,代码行数:15,代码来源:SubscribeNewsletterController.cs

示例3: Subscribe_Successful

        public void Subscribe_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            EmailParameter email = new EmailParameter()
            {
                Email = "[email protected]"
            };

            //  Act
            EmailParameter results = mc.Subscribe(lists.Data[1].Id, email);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
        }
开发者ID:RomeoQNgo,项目名称:MailChimp.NET,代码行数:17,代码来源:ListTests.cs

示例4: Subscribe

        public bool Subscribe(string email, int domainID)
        {
            tbl_Domains domain = DomainsRepository.GetByID(domainID);
            if (domain == null || !domain.DO_EnableMailChimp)
                return false;

            MailChimpManager manager = new MailChimpManager(domain.DO_MailChimpAPIKey);
            EmailParameter emailParam = new EmailParameter() { Email = email };
            try
            {
                var val = manager.Subscribe(domain.DO_MailChimpListID, emailParam, updateExisting: true);
                return val != null ? true : false;
            }
            catch (MailChimpAPIException e)
            {
                Log.Error(String.Format("MailChimp Subscribe: Subscription exception: \"{0}\" ,for \"{1}\"", e.MailChimpAPIError.Name, email), e);
            }
            return false;
        }
开发者ID:nhtera,项目名称:CrowdCMS,代码行数:19,代码来源:MailChimp.cs

示例5: AddSubscriber

        // MailChimp campaign methods
        public EmailParameter AddSubscriber(string emailAddress, string fname, string lname)
        {
            var list = _listId;

            Models.MailChimpCampaignModel.MergeFields userFields = new Models.MailChimpCampaignModel.MergeFields();
            userFields.FirstName = fname;
            userFields.LastName = lname;

            MailChimpManager mc = new MailChimpManager(_apiKey);

            EmailParameter email = new EmailParameter()
            {
                Email = emailAddress
            };

            EmailParameter result = mc.Subscribe(list, email, userFields);

            return result;
        }
开发者ID:thedevhunter,项目名称:MiDinero-MiFuturo,代码行数:20,代码来源:EmailCampaignService.cs

示例6: Subscribe

        public IHttpActionResult Subscribe(string subscribeEmail)
        {
            EmailParameter result;
            if (!string.IsNullOrEmpty(_mailingSettings.AccessToken) && !string.IsNullOrEmpty(_mailingSettings.AccessToken) && !string.IsNullOrEmpty(_mailingSettings.SubscribersListId) &&
                subscribeEmail.Contains("@") && subscribeEmail.Contains("."))
            {
                var mc = new MailChimpManager(_mailingSettings.AccessToken, _mailingSettings.DataCenter);

                //  Create the email parameter
                var email = new EmailParameter()
                {
                    Email = subscribeEmail,
                };

                result = mc.Subscribe(_mailingSettings.SubscribersListId, email);
                if (string.IsNullOrEmpty(result.EUId))
                    return BadRequest();
            }
            else
            {
                return BadRequest();
            }
            return Ok(result);
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:24,代码来源:MailChimpController.cs

示例7: AddEmail

        public static EmailParameter AddEmail(string email)
        {
            try
            {
                var apiKey = ConfigurationManager.AppSettings["MailChimpApiKey"];
                var listId = ConfigurationManager.AppSettings["MailChimpListId"];

                var mc = new MailChimpManager(apiKey);

                //  Create the email parameter
                var emailParam = new EmailParameter()
                {
                    Email = email
                };

                var result = mc.Subscribe(listId, emailParam, doubleOptIn: false);
                return result;
            }
            catch (Exception)
            {
            }

            return null;
        }
开发者ID:RobRattray,项目名称:OneLifeLiveIt,代码行数:24,代码来源:MailChimpHelper.cs

示例8: SubscribeWithGroupSelection_Successful

        public void SubscribeWithGroupSelection_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            EmailParameter email = new EmailParameter()
            {
                Email = "[email protected]"
            };

            // find a list with interest groups...
            string strListID = null;
            int nGroupingID = 0;
            string strGroupName = null;
            foreach (ListInfo li in lists.Data) {
                List<InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
                if (interests != null) {
                    if (interests.Count > 0) {
                        if (interests[0].GroupNames.Count > 0) {
                            strListID = li.Id;
                            nGroupingID = interests[0].Id;
                            strGroupName = interests[0].GroupNames[0].Name;
                            break;
                        }
                    }
                }
            }
            Assert.IsNotNull(strListID,"no lists found in this account with groupings / group names");
            Assert.AreNotEqual(0,nGroupingID);
            Assert.IsNotNull(strGroupName);

            MyMergeVar mvso = new MyMergeVar();
            mvso.Groupings = new List<Grouping>();
            mvso.Groupings.Add(new Grouping());
            mvso.Groupings[0].Id = nGroupingID;
            mvso.Groupings[0].GroupNames = new List<string>();
            mvso.Groupings[0].GroupNames.Add(strGroupName);
            mvso.FirstName = "Testy";
            mvso.LastName = "Testerson";

            //  Act
            EmailParameter results = mc.Subscribe(strListID, email, mvso);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
        }
开发者ID:CaudronThomas,项目名称:MailChimp.NET,代码行数:47,代码来源:ListTests.cs

示例9: RegisterHouseholdMembers

        public ActionResult RegisterHouseholdMembers(HouseholdMemberModel householdMemberModel)
        {
            AddressModel address = new UserService().GetAddressById(householdMemberModel.AddressId);

            //Don't allow duplicate user
            var tryToFindUser = Membership.GetUserNameByEmail(householdMemberModel.Email);
            if (string.IsNullOrEmpty(tryToFindUser))
            {

                var id = Guid.NewGuid();

                Boolean isFBUser = false;
                Boolean isApproved = true;
                Int32 FBUserId = 0;

                // create the ASP membership user
                MembershipCreateStatus status;
                var membershipUser = Membership.CreateUser(username: householdMemberModel.Email, password: householdMemberModel.Password, email: householdMemberModel.Email,
                    passwordQuestion: null, passwordAnswer: null,
                    isApproved: isApproved, providerUserKey: id,
                    status: out status
                );

                // Check inviter user role and the same role for invited user
                var addressHolderUserEmail = new UserService().GetUserNameHolderForAddress(householdMemberModel.AddressId);
                if (!string.IsNullOrWhiteSpace(addressHolderUserEmail))
                {
                    if (Roles.IsUserInRole(addressHolderUserEmail, "Supplier") && membershipUser != null)
                    {
                        Roles.AddUserToRole(membershipUser.Email, "Supplier");
                    }
                }

                if (status == MembershipCreateStatus.Success)
                {
                    // create the GM user
                    var user = new UserModel
                    {
                        Id = id,
                        FirstName = householdMemberModel.FirstName,
                        LastName = householdMemberModel.LastName,
                        AddressModel = address,
                        AddressId = address.Id,
                        Instance_Id = address.Instance_Id,
                        SendEmailOffers = householdMemberModel.SendEmailOffers,
                        SendEmailUpdates = householdMemberModel.SendEmailUpdates,
                        IsFBAccount = isFBUser,
                        FBUserId = FBUserId,
                        IsAdditionalAccountHolder = true
                    };

                    // Give them the New Member Bonus
                    int numBonusPoints = Convert.ToInt16(ConfigurationManager.AppSettings["BonusPoints.NewMember.Points"]);
                    string descBonusPoints = Convert.ToString(ConfigurationManager.AppSettings["BonusPoints.NewMember.Description"]);
                    int? transactionTypeId = Convert.ToInt16(ConfigurationManager.AppSettings["TransactionType.ShareHeart"]);

                    // store it
                    var newUser = new UserService().CreateUser(user, numBonusPoints, descBonusPoints, transactionTypeId);

                    int numBonusInvitationAcceptedPoints = Convert.ToInt16(ConfigurationManager.AppSettings["BonusPoints.InviteMember.Points"]);
                    string descInvitationAcceptedBonusPoints = Convert.ToString(ConfigurationManager.AppSettings["BonusPoints.InviteMember.Description"]);

                    bool addPoints = new UserService().InvitationAcceptedAddBonusPoints(addressHolderUserEmail,
                        numBonusInvitationAcceptedPoints, descInvitationAcceptedBonusPoints, transactionTypeId);

                    SendVerifyEmail(membershipUser.Email, user.FirstName, user.Id, true);

                    bool isProduction = Convert.ToBoolean(ConfigurationManager.AppSettings["MailChimp.ListId"]);

                    if (isProduction)
                    {
                        // Add them to the relevant MailChimp List
                        MailChimpManager mc = new MailChimpManager(ConfigurationManager.AppSettings["MailChimp.APIKey"]);
                        EmailParameter email = new EmailParameter()
                        {
                            Email = user.Email
                        };

                        EmailParameter results = mc.Subscribe(ConfigurationManager.AppSettings["MailChimp.ListId"], email);

                    }

                    return RedirectToAction("RegisterAccountSuccess");

                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(status));
                    return View(householdMemberModel);
                }
            }
            else
            {
                // email has already been registered in the system
                ModelState.AddModelError("", "User with the same email address has already been registered with GreenMoney.");
                return View(householdMemberModel);

            }
        }
开发者ID:salebgmilj2,项目名称:GreenMoney,代码行数:99,代码来源:AccountController.cs

示例10: SubscribeWithGroupSelectionUsingDictonary_Successful

				public void SubscribeWithGroupSelectionUsingDictonary_Successful() {
					//  Arrange
					MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
					ListResult lists = mc.GetLists();
					EmailParameter email = new EmailParameter() {
						Email = "[email protected]"
					};

					// find a list with interest groups...
					string strListID = null;
					int nGroupingID = 0;
					string strGroupName = null;
					foreach (ListInfo li in lists.Data) {
						List<InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
						if (interests != null) {
							if (interests.Count > 0) {
								if (interests[0].GroupNames.Count > 0) {
									strListID = li.Id;
									nGroupingID = interests[0].Id;
									strGroupName = interests[0].GroupNames[0].Name;
									break;
								}
							}
						}
					}
					Assert.IsNotNull(strListID, "no lists found in this account with groupings / group names");
					Assert.AreNotEqual(0, nGroupingID);
					Assert.IsNotNull(strGroupName);

					MergeVar mvso = new MergeVar();
					mvso.Groupings = new List<Grouping>();
					mvso.Groupings.Add(new Grouping());
					mvso.Groupings[0].Id = nGroupingID;
					mvso.Groupings[0].GroupNames = new List<string>();
					mvso.Groupings[0].GroupNames.Add(strGroupName);
					mvso.Add("FNAME","Testy" + DateTime.Now);
					mvso.Add("LNAME", "Testerson" + DateTime.Now);

					//  Act
					EmailParameter results = mc.Subscribe(strListID, email, mvso);

					//  Assert
					Assert.IsNotNull(results);
					Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));

					// load
					List<EmailParameter> emails = new List<EmailParameter>();
					emails.Add(results);
					MemberInfoResult memberInfos = mc.GetMemberInfo(strListID, emails);

					// Assert
					Assert.AreEqual(1, memberInfos.SuccessCount);
					Assert.AreEqual(2, memberInfos.Data[0].MemberMergeInfo.Count);
					Assert.AreEqual(mvso["FNAME"], memberInfos.Data[0].MemberMergeInfo["FNAME"]);
					Assert.AreEqual(mvso["LNAME"], memberInfos.Data[0].MemberMergeInfo["LNAME"]);

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

示例11: UpdateMember_Successful

        public void UpdateMember_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            EmailParameter email = new EmailParameter()
            {
                Email = "[email protected]"
            };
            var listId = lists.Data[0].Id;
            MyMergeVar mergeVar = new MyMergeVar();
            EmailParameter subscriptionResults = mc.Subscribe(listId, email, mergeVar, "html", false, true);

            //  Act
            mergeVar.FirstName = "some name";
            mc.UpdateMember(listId, subscriptionResults, mergeVar);

            // load
            List<EmailParameter> emails = new List<EmailParameter>();
            emails.Add(email);
            MemberInfoResult memberInfos = mc.GetMemberInfo(listId, emails);

            //  Assert
            Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.ContainsKey("FNAME"));
            Assert.AreEqual("some name", memberInfos.Data[0].MemberMergeInfo["FNAME"]);
        }
开发者ID:erpframework,项目名称:MailChimp.NET,代码行数:26,代码来源:ListTests.cs


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