Exemplo n.º 1
0
        public void LiveUpdateFailedForScheduledCampaignTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var camp = new EmailCampaign
            {
                EmailContent = "<html><body>EMAIL CONTENT.</body></html>",
                Subject = "campaign subject",
                FromName = "my company",
                FromEmail = CustomerEmail,
                ReplyToEmail = CustomerEmail,
                Name = "campaign_" + DateTime.Now.ToString("yyMMddHHmmss"),
                TextContent = "email campaign text content",
                GreetingString = "Dear ",
                //TemplateType = TemplateType.CUSTOM,
                Status = CampaignStatus.DRAFT,
                EmailContentFormat = CampaignEmailFormat.HTML,
                StyleSheet = "",
                MessageFooter = new MessageFooter
                {
                    OrganizationName = "my organization",
                    AddressLine1 = "123 Mapple Street",
                    AddressLine2 = "Suite 1",
                    AddressLine3 = "",
                    City = "Boston",
                    State = "MA",
                    PostalCode = "02101",
                    Country = "US",
                    IncludeForwardEmail = true,
                    ForwardEmailLinkText = "forward link",
                    IncludeSubscribeLink = true,
                    SubscribeLinkText = "subscribe link"
                }
                ,
                Lists = new List<SentContactList> { new SentContactList { Id = "1" } }
            };
            camp = cc.AddCampaign(camp);
            Assert.IsNotNull(camp);
            Assert.IsNotNull(camp.Id);

            DateTime schDate = DateTime.Now.AddMonths(1);
            Schedule schedule = cc.AddSchedule(camp.Id, new Schedule { ScheduledDate = schDate });
            Assert.IsNotNull(schedule);
            Assert.AreNotEqual(0, schedule.Id);
            Assert.IsNotNull(schedule.ScheduledDate);

            camp.GreetingName = GreetingName.FIRST_AND_LAST_NAME;

            var updatedCampaign = cc.UpdateCampaign(camp);
            Assert.IsNull(updatedCampaign);
        }