.net - 使用 Mailchimp.net API 检查电子邮件是否存在

标签 .net mailchimp subscribe

我在这里使用 MailChimp.net api:https://github.com/danesparza/MailChimp.NET

这是我目前拥有的代码,它适用于订阅用户到我的列表,但显然当邮件已经存在于 mailchimp 列表中时它会抛出异常,并且 API 还没有完全完成,所以不是所有的 mailchimp我可以使用方法。

 //SUBSCRIBE IN MAILCHIMP
 MailChimpManager mc = new MailChimpManager("**API-KEY**");
 //  Create the email parameter
 EmailParameter subscriber = new EmailParameter()
 {
     Email = model.email
 };

 EmailParameter results = mc.Subscribe("**LIST-ID*", subscriber);

我一直在尝试做这样的事情:

mc.GetMemberInfo("**LIST-ID**", "member email");

但我不知道正确的语法或者这是否是正确的使用方法。

Mailchimp 没有给我一个处理异常的明确方法,我也不是最好的后端开发人员。我知道我需要检查电子邮件是否存在于列表中,只需要一点帮助即可。

感谢大家的帮助!

最佳答案

你应该能够做这样的事情:

MailChimpManager mc = new MailChimpManager(** apikey **);

var emails = new List<EmailParameter>();
emails.Add(new EmailParameter() { Email = ** youremail ** });

var info = mc.GetMemberInfo(** listid **, emails);
var member = info.Data.SingleOrDefault();

if (member.Status == "subscribed") {
    ** email is subscribed **
}
else {
    ** email is not subscribed **
}

关于.net - 使用 Mailchimp.net API 检查电子邮件是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20885410/

相关文章:

.net - 令人惊讶的性能差异 : List. Contains、SortedList.ContainsKey、DataRowCollection.Contains、Data Table.Select、DataTable.FindBy

css - 图像上的通讯图像

Angular 5 订阅不是一个函数

php - mailchimp 模板 mc :edit not showing images

python - 在 python 中使用 paho mqtt 处理收到的消息

javascript - 简单 meteor (1.7.0.5) 发布/订阅集合不起作用

c# - InstallShield 和 ConfuserEx

c# - 是否可以从另一个表单触发点击事件?

使用 Where 子句的 C# 结果序列

email - 如何将 MailChimp 设计的事件转换为 Mandrill 中的模板?