I am trying to send an email by using MailChimp. Our project is .net core application but something wrong here. Maybe, I am doing something wrong but I couldn't find an exact solution for that. There is no simple mail send in mailchimp.net. How can I send an email by using 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 = "[email protected]",
EmailType = "html",
Status = Status.Subscribed
});
var _campaignSettings = new Setting
{
ReplyTo = "[email protected]",
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();
}
question from:
https://stackoverflow.com/questions/65923182/how-can-i-use-mailchimp-net-for-sending-simple-email-to-an-email-by-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…