在asp.net中发送mailchimp广告系列

时间:2011-11-27 12:05:22

标签: c# asp.net mailchimp

我正在尝试使用asp.net发送邮件黑猩猩活动,实际上我成功创建了广告系列,我可以通过我的个人资料看到它但我想通过我的代码发送它是我的代码所以如果有的话可以帮忙!!

private static void CreateCampaignAndSend(string apiKey, string listID)
        {
            Int32 TemplateID = 0;
            string campaignID = string.Empty;



            // compaign Create Options
            var campaignCreateOpt = new campaignCreateOptions
                                        {
                                            list_id = listID,
                                            subject = "subject",
                                            from_email = "cbx@abc.com",
                                            from_name = "abc",
                                            template_id = TemplateID
                                        };

            // Content

            var content = new Dictionary<string, string>
                              {
                                  {"html", "Lots of cool stuff here."}
                              };

            // Conditions
            var csCondition = new List<campaignSegmentCondition>();
            var csC = new campaignSegmentCondition {field = "interests-" + 123, op = "all", value = ""};

            csCondition.Add(csC);

            // Options
            var csOptions = new campaignSegmentOptions {match = "all"};


            // Type Options
            var typeOptions = new Dictionary<string, string>
                                  {
                                      {"offset-units", "days"},
                                      {"offset-time", "0"},
                                      {"offset-dir", "after"}
                                  };

            // Create Campaigns

            var campaignCreate = new campaignCreate(new campaignCreateInput(apiKey, EnumValues.campaign_type.plaintext, campaignCreateOpt, content, csOptions, typeOptions));
            campaignCreateOutput ccOutput = campaignCreate.Execute();
            campaignSendNow c=new campaignSendNow();
            List<Api_Error> error = ccOutput.api_ErrorMessages;  // Catching API Errors


            if (error.Count <= 0)
            {
                campaignID = ccOutput.result;
            }
            else
            {
                foreach (Api_Error ae in error)
                {
                    Console.WriteLine("\n ERROR Creating Campaign : ERRORCODE\t:" + ae.code + "\t ERROR\t:" + ae.error);

                }
            }

        }

0 个答案:

没有答案