Exemple #1
0
        private void frmEmailCampaign_Load(object sender, EventArgs e)
        {
            try
            {
                string state = "ok";
                _accessToken = OAuth.AuthenticateFromWinProgram(ref state);

                if (string.IsNullOrEmpty(_accessToken))
                {
                    Application.Exit();
                }

                //initialize ConstantContact members
                IUserServiceContext    userServiceContext      = new UserServiceContext(_accessToken, _apiKey);
                ConstantContactFactory _constantContactFactory = new ConstantContactFactory(userServiceContext);
                _emailCampaignService         = _constantContactFactory.CreateEmailCampaignService();
                _emailCampaginScheduleService = _constantContactFactory.CreateCampaignScheduleService();
                _listService    = _constantContactFactory.CreateListService();
                _accountService = _constantContactFactory.CreateAccountService();
            }
            catch (OAuth2Exception oauthEx)
            {
                MessageBox.Show(string.Format("Authentication failure: {0}", oauthEx.Message), "Warning");
            }

            PopulateCampaignTypeList();
            PopulateListOfCountries();
            PopulateUSAndCanadaListOfStates();

            GetListOfContacts();
            PopulateEmailLists();
        }
Exemple #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            _apiKey             = ConfigurationManager.AppSettings["APIKey"];
            Session["campaign"] = TextBox1.Text;
            try
            {
                string state = "ok";
                OAuth.AuthorizeFromWebApplication(HttpContext.Current
                                                  , state);


                //initialize ConstantContact members
                IUserServiceContext    userServiceContext      = new UserServiceContext(_accessToken, _apiKey);
                ConstantContactFactory _constantContactFactory = new ConstantContactFactory(userServiceContext);
                _emailCampaignService         = _constantContactFactory.CreateEmailCampaignService();
                _emailCampaginScheduleService = _constantContactFactory.CreateCampaignScheduleService();
                _listService    = _constantContactFactory.CreateListService();
                _accountService = _constantContactFactory.CreateAccountService();
            }
            catch (OAuth2Exception oauthEx)
            {
                //  MessageBox.Show(string.Format("Authentication failure: {0}", oauthEx.Message), "Warning");
            }


            //PopulateListOfCountries();
            //PopulateUSAndCanadaListOfStates();

            //GetListOfContacts();
            //PopulateEmailLists();
        }