如何在 C#/.Net 中集成 MailChimp

发布于 2024-11-03 17:54:51 字数 61 浏览 0 评论 0原文

我想通过 MailChimp 发送电子邮件。如何在.Net 中做到这一点?

有人有示例代码吗?

I want to send email through MailChimp. How to do this in .Net?

Does any one have sample code?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇纵 2024-11-10 17:54:51

下面的示例将发送一封选择加入的电子邮件:

首先安装 NuGet 包:Install-Package mcapi.net

    static void Main(string[] args)
    {
        const string apiKey = "6ea5e2e61844608937376d514-us2";   // Replace it before
        const string listId = "y657cb2495";                      // Replace it before

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

        var mergeText = new List.Merges("[email protected]", List.EmailType.Text)
                    {
                        {"FNAME", "John"},
                        {"LNAME", "Smith"}
                    };
        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)
            Console.WriteLine("Error:{0}", batchSubscribe.Errors[0].Message);
        else
            Console.WriteLine("Success");

        Console.ReadKey();
    }

The example below will send a opt-in email:

First install the NuGet package: Install-Package mcapi.net

    static void Main(string[] args)
    {
        const string apiKey = "6ea5e2e61844608937376d514-us2";   // Replace it before
        const string listId = "y657cb2495";                      // Replace it before

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

        var mergeText = new List.Merges("[email protected]", List.EmailType.Text)
                    {
                        {"FNAME", "John"},
                        {"LNAME", "Smith"}
                    };
        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)
            Console.WriteLine("Error:{0}", batchSubscribe.Errors[0].Message);
        else
            Console.WriteLine("Success");

        Console.ReadKey();
    }
幽蝶幻影 2024-11-10 17:54:51

请查看 Dan 的 https://github.com/danesparza/MailChimp.NET埃斯帕扎
您可以使用程序包管理器控制台安装程序包

Install-Package MailChimp.NET

代码示例

MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");
ListResult lists = mc.GetLists();

对于电子邮件发送和统计信息,Mailchimp提供 >Mandrill 作者:Shawn Mclean https://github.com/shawnmclean/Mandrill-dotnet

安装Mandrill

Install-Package Mandrill

您可以使用代码示例

MandrillApi api = new MandrillApi("xxxxx-xxxx-xxxx-xxxx");
UserInfo info = await api.UserInfo();

Do Check out https://github.com/danesparza/MailChimp.NET by Dan Esparza
You can install the package by using Package Manager Console

Install-Package MailChimp.NET

Code example

MailChimpManager mc = new MailChimpManager("YourApiKeyHere-us2");
ListResult lists = mc.GetLists();

For email sending and stats, Mailchimp offers Mandrill by Shawn Mclean https://github.com/shawnmclean/Mandrill-dotnet

You can install Mandrill using

Install-Package Mandrill

Code example

MandrillApi api = new MandrillApi("xxxxx-xxxx-xxxx-xxxx");
UserInfo info = await api.UserInfo();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文