public List.Merges GetListOfMerges(PlayersExt model)
        {
            var merge = new List.Merges(model.EmailAddress, List.EmailType.Html)
                    {
                        {"FNAME", model.FirstName},
                        {"LNAME", model.LastName},
                        {"PHONE", model.Mobile},
                        {"DOB", model.DOB},
                        {"MOBNUM", model.Mobile},
                        {"REGDATE", model.RegistrationDate},
                        {"WEIGHT", model.Weight},
                        {"HEIGHT", model.Height},
                        {"AVGACTLEV", model.HowActiveAreYou},
                        {"POSITION", model.PrefferredPosition},
                        {"BMI", model.BMI},
                        {"BODYFAT", model.BodyFat},
                        {"ADDLINE1", model.AddressLine1},
                        {"ADDLINE2", model.AddressLine2},
                        {"CITY", model.City},
                        {"POSTCODE", model.PostCode},
                        {"LEAGUE", model.SelectedLeagueName},

                    };

            return merge;
        }
        protected void AddEmailToMailChimp(string email, string firstName, string lastName, string listId)
        {
            string apiKey = ConfigurationManager.AppSettings["MailChimpApiKey"];


            var options = new List.SubscribeOptions();

            options.DoubleOptIn = true;
            options.EmailType   = List.EmailType.Html;
            options.SendWelcome = true;

            var mergeText = new List.Merges(email, List.EmailType.Text)
            {
                { "FNAME", firstName },
                { "LNAME", lastName }
            };
            var merges = new List <List.Merges> {
                mergeText
            };

            var mcApi          = new MCApi(apiKey, false);
            var batchSubscribe = mcApi.ListBatchSubscribe(listId, merges, options);

            if (batchSubscribe.Errors.Count > 0)
            {
                _logger.Error(batchSubscribe.Errors[0].Message, null);
            }
        }
        public List.Merges GetListOfMerges_SingleSignUp(string EmailAddress)
        {
            var merge = new List.Merges(EmailAddress, List.EmailType.Html)
                    {
                        {"SOURCE", "MANvFAT Footer Signup"}
                    };

            return merge;
        }
Exemple #4
0
        public Dictionary <string, string> SubscribeBatch(DataTable subscribers)
        {
            var mc = new MCApi(_apiKey, true);
            var subscribeOptions =
                new List.SubscribeOptions
            {
                DoubleOptIn    = false,
                SendWelcome    = true,
                UpdateExisting = true,
            };

            var merges = new List <List.Merges>();

            Dictionary <int, string> fields = GetFieldsName(subscribers);

            try
            {
                subscribers.Columns["EMAIL"].AllowDBNull = false;
            }
            catch (Exception ex)
            {
                throw new DuradosException("Email is missing", ex);
            }
            try
            {
                subscribers.PrimaryKey = new DataColumn[] { subscribers.Columns["EMAIL"] };
            }
            catch (Exception ex)
            {
                throw new DuradosException("Email must be unique", ex);
            }


            foreach (DataRow row in subscribers.Rows)
            {
                var merge = new List.Merges();

                for (int i = 0; i < subscribers.Columns.Count; i++)
                {
                    string val = row[i].ToString();
                    if (subscribers.Columns[i].DataType == typeof(bool))
                    {
                        val = Convert.ToInt32(row.IsNull(i) ? false : row[i]).ToString();
                    }
                    merge.Add(fields[i], val);
                }
                merges.Add(merge);
            }
            if (merges.Count == 0)
            {
                return(null);
            }
            List.BatchSubscribe lbs = mc.ListBatchSubscribe(_listId, merges, subscribeOptions);

            return(GetErrors(subscribers, lbs));
        }
 public bool UpdateSubscriberEmail(string oldEmail, string newEmail, string apiKey)
 {
     var mcApi = new MCApi(apiKey, true);
     var merges = new List.Merges();
     var subscriptionOptions = new List.SubscribeOptions();
     subscriptionOptions.UpdateExisting = true;
     subscriptionOptions.DoubleOptIn = false;
     subscriptionOptions.SendWelcome = false;
     return mcApi.ListUpdateMember().ListSubscribe(list, email, merges, subscriptionOptions);
 }
        public static void AccedeApi(string nombre, string apPaterno, string correo)
        {
            const string apiKey  = "eef4bc1722806a84538bc67d058b44c0-us7"; // Replace it before
            string       listId  = "c9ad222383";                           // Replace it before
            string       listId1 = "e321ec7f9d";

            var options = new List.SubscribeOptions
            {
                DoubleOptIn = true, EmailType = List.EmailType.Html, SendWelcome = false
            };

            //var entry = new Dictionary<string, object>();
            //entry.Add("FNAME", "Sergio");
            //entry.Add("LNAME", "Alvarez");

            //var lsi =  new listSubscribe(apiKey, listId, "*****@*****.**", entry);


            var mergeText = new List.Merges()
            {
                { "FNAME", nombre },
                { "LNAME", apPaterno }
            };
            //var merges = new List<List.Merges> { mergeText };

            var mcApi = new MCApi(apiKey, false);


            mcApi.ListSubscribe(listId, correo, mergeText, options);
            //mcApi.ListMergeVarAdd(listId, "Test", "Testing");


            //var lstMailChimp = mcApi.ListClients("e321ec7f9d");
            //mcApi.ListMembers("e321ec7f9d", List.MemberStatus.Subscribed).Data[1];
            //mcApi.ListSubscribe(listId, "*****@*****.**");

            //var listaClientes = mcApi.ListMembers(listId, List.MemberStatus.Subscribed).Data;
            //var lstMember = mcApi.ListMergeVars(listId);

            //foreach (var item in listaClientes)
            //{
            //    var email = item.Email;
            //    var description = item.Description;
            //    var reason = item.Reason;
            //    var timestamp = item.Timestamp;
            //}

            //foreach (var mergeVar in lstMember)
            //{
            //    var name = mergeVar.Name;
            //    var ejemplo = mergeVar.HelpText[0];
            //}
        }
		public bool AddToMailingList(string firstName, string lastName, string email, int list = 0)
		{
			MCApi server = new MCApi(mailingListToken, false);
			List.Merges merge_vars = new List.Merges();
			merge_vars.Add("fName", firstName);
			merge_vars.Add("lName", lastName);
			string mailChimpList;
			switch (list)
			{
				case 1: mailChimpList = mailChimpGeneralList; break;
				default: mailChimpList = mailChimpIBOList; break;
			}
			server.ListSubscribe(mailChimpIBOList, email, merge_vars);
			return false;
		}
 public bool AddOrUpdateSubscriber(string email, string list, string apiKey, string firstName, string lastName, string title, string company, string guid)
 {
     var mcApi = new MCApi(apiKey, true);
     var merges = new List.Merges();
     merges.Add("FNAME", firstName);
     merges.Add("LNAME", lastName);
     merges.Add("TITLE", title);
     merges.Add("COMPANY", company);
     merges.Add("GUID", guid);
     var subscriptionOptions = new List.SubscribeOptions();
     subscriptionOptions.UpdateExisting = true;
     subscriptionOptions.DoubleOptIn = false;
     subscriptionOptions.SendWelcome = false;
     return mcApi.ListSubscribe(list, email, merges, subscriptionOptions);
 }
        protected void btnSuscribir_Click(object sender, EventArgs e)
        {
            String resultado = "";

            try
            {
                const string apiKey = "a3bcf72bb39572c06e9d2a3747cd8eaa-us3"; // Replace it before
                const string listId = "41afc6c854";                           // Replace it before

                var options = new List.SubscribeOptions();
                options.DoubleOptIn = true;
                options.EmailType   = List.EmailType.Html;
                options.SendWelcome = false;

                var mergeText = new List.Merges(txtSuscribir.Text, List.EmailType.Text);
                var merges    = new List <List.Merges> {
                    mergeText
                };

                var mcApi          = new MCApi(apiKey, false);
                var batchSubscribe = mcApi.ListBatchSubscribe(listId, merges, options);


                if (batchSubscribe.Errors.Count > 0)
                {
                    resultado = "?ress=error";
                    System.Diagnostics.Debug.WriteLine("Error:{0}", batchSubscribe.Errors[0].Message);
                }
                else
                {
                    resultado = "?ress=succ";
                    System.Diagnostics.Debug.WriteLine("Success");
                }
            }
            catch (MailChimp.Types.MCException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                Response.Redirect("Default.aspx" + resultado);
            }
        }
        }         // GetGroups

        private List.Merges SubscriberToEntry(Subscriber subscriber, Func <Subscriber, string> oExtractEmail)
        {
            var group  = new[] { subscriber.Group };
            var groups = new[] { new List.Grouping(int.Parse(Constants.SignUpProcessGroupId), group) };

            var entry = new List.Merges(oExtractEmail(subscriber), List.EmailType.Html, groups);

            if (!string.IsNullOrEmpty(subscriber.FirstName))
            {
                entry.Add(Constants.FirstNameField, subscriber.FirstName);
            }

            if (subscriber.LoanOffer > 0)
            {
                entry.Add(Constants.LoanOfferField, subscriber.LoanOffer);
            }

            if (subscriber.DayAfter.HasValue)
            {
                entry.Add(Constants.DayAfterConditionField, subscriber.DayAfter);
            }

            //if (subscriber.ThreeDays.HasValue)
            //	entry.Add(Constants.ThreeDaysConditionField, subscriber.ThreeDays);

            if (subscriber.Week.HasValue)
            {
                entry.Add(Constants.WeekConditionField, subscriber.Week);
            }

            if (subscriber.TwoWeeks.HasValue)
            {
                entry.Add(Constants.TwoWeeksConditionField, subscriber.TwoWeeks);
            }

            if (subscriber.Month.HasValue)
            {
                entry.Add(Constants.MonthConditionField, subscriber.Month);
            }

            return(entry);
        }         // SubscriberToEntry
Exemple #11
0
        public static bool testUserSignup(string email, string firstName, string lastName, string phone, string companyName, string cvr)
        {
            if (email != null && firstName != null && lastName != null && phone != null && companyName != null && cvr != null)
            {
                MCApi mc = new MCApi(apiKey, true);

                List.Merges merges = new List.Merges();
                merges.Add("FNAME", firstName);
                merges.Add("LNAME", lastName);
                merges.Add("CNAME", companyName);
                merges.Add("CVR", cvr);
                merges.Add("PHONE", phone);

                if (mc.ListSubscribe("908bfd3981", email, merges))
                {
                    return true;
                }
            }

            return false;
        }
Exemple #12
0
        /// <summary>
        /// This function will add user to Mailchimp Subscription List
        /// </summary>
        /// <param name="emailId">EmailId of the user</param>
        /// <param name="firstName">First Name of the user</param>
        /// <param name="LastName">Last Name of the User</param>
        /// <param name="isSubscribeOnly">Checks if this is only subscribtion . while registering we'll add user to list , but we'll send subscription mail to user..in that case it'll be false.</param>
        /// <returns></returns>
        public string SaveToMailChimpList(string emailId, string firstName, string LastName,bool isSubscribeOnly)
        {
            MCApi api = new MCApi(ConfigurationManager.AppSettings["MailChimpApiKey"], false);

            List.Filter lf = new List.Filter();
            lf.ListName = ConfigurationManager.AppSettings["MailChimpListName"];
            List.Lists lists = api.Lists(lf);

            if (lists.Total > 0)
            {
                string listId = lists.Data[0].ListID;

                List.SubscribeOptions so = new List.SubscribeOptions();
                so.DoubleOptIn = false;

                List.Merges merges = new List.Merges();
                merges.Add("FNAME", firstName);
                merges.Add("LNAME", LastName);
                var uservailble = api.ListMemberInfo(listId, emailId);
                if (uservailble.Data[0].Email==null)
                {
                    if (api.ListSubscribe(listId, emailId, merges, so))
                    {
                        //send mail to user
                        if (isSubscribeOnly)
                        {
                            //send emailid in place of mail because name is empty in this case.
                            NotifyUser(emailId, emailId, "Thanks for showing interest in LockYourStay!", "Thank you for subscribing Lockyourstay.We will keep you posted with all updates.", "Notify User");
                        }
                        return "Thank you for your subscription!";
                    }
                    else
                    {
                        return "Something went wrong! Please try again later.";
                    }
                }
                else
                {
                    return "Email already exists!";
                }
            }
            else
            {
                //no list available
                return "Something went wrong! Please try again later.";
            }
        }
        protected  void AddEmailToMailChimp(string email, string firstName, string lastName, string listId)
        {
            string apiKey = ConfigurationManager.AppSettings["MailChimpApiKey"];
            

            var options = new List.SubscribeOptions();
            options.DoubleOptIn = true;
            options.EmailType = List.EmailType.Html;
            options.SendWelcome = true;

            var mergeText = new List.Merges(email, List.EmailType.Text)
                    {
                        {"FNAME", firstName},
                        {"LNAME", lastName}
                    };
            var merges = new List<List.Merges> { mergeText };

            var mcApi = new MCApi(apiKey, false);
            var batchSubscribe = mcApi.ListBatchSubscribe(listId, merges, options);

            if (batchSubscribe.Errors.Count > 0)
            {
                _logger.Error(batchSubscribe.Errors[0].Message, null);
            }
        }