问题描述
我正在尝试使用 MailChimp 发送电子邮件。我们的项目是 .net 核心应用程序,但这里出了点问题。也许,我做错了什么,但我找不到确切的解决方案。 mailchimp.net 中没有简单的邮件发送。如何使用 MailChimp.net 发送电子邮件?
static async void Run()
{
MailChimpManager _mailChimpManager = new MailChimpManager(ApiKey);
var list = _mailChimpManager.Lists.AddOrUpdateAsync(new List() { Contact = new Contact() { Address1 = "test5" },});
var r = _mailChimpManager.Lists.GetAllAsync().GetAwaiter();
var m = _mailChimpManager.Members.AddOrUpdateAsync(list.Id.ToString(),new Member
{
EmailAddress = "test@gmail.com",EmailType = "html",Status = Status.Subscribed
});
var _campaignSettings = new Setting
{
ReplyTo = "test1@yahoo.com",FromName = "The name that others will see when they receive the email",Title = "Your campaign title",SubjectLine = "The email subject",};
var campaign = _mailChimpManager.Campaigns.AddAsync(new Campaign
{
Settings = _campaignSettings,Recipients = new Recipient { ListId = list.Id.ToString() },Type = CampaignType.Regular
}).Result;
var timeStr = DateTime.Now.ToString();
var content = _mailChimpManager.Content.AddOrUpdateAsync(
campaign.Id,new ContentRequest()
{
Template = new ContentTemplate
{
Id = TemplateId,Sections = new Dictionary<string,object>()
{
{ "body_content","<h1>Test</h1>" },{ "preheader_leftcol_content",$"<p>{timeStr}</p>" }
}
}
}).Result;
_mailChimpManager.Campaigns.SendAsync(campaign.Id).Wait();
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)