在 asp.net 中发送 mailchimp 活动

发布于 2024-12-18 17:03:17 字数 2636 浏览 0 评论 0原文

我正在尝试使用 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 = "[email protected]",
                                            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);

                }
            }

        }

I'm trying to send a mail chimp campaign using asp.net, actually i created successfully the campaign and i can see it through my profile but also i want to send it through my code here is my code so if any one can help!!

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 = "[email protected]",
                                            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);

                }
            }

        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文