How to integrate the MailChimp in .net core for sending email. Please provide an example
Loading
How to integrate the MailChimp in .net core for sending email. Please provide an example
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 28, 2024, 6:08 AM EDT
Hi,
Check this article reference:
https://www.c-sharpcorner.com/article/send-email-using-asp-net-core-1-1-with-mailkit-in-visual-studio-2017/
Sourabh DhimanRank #2,987 · 483 reputationPosted Jun 28, 2024, 6:13 AM EDT
This is used mail kit , I want to with mailChimp
Jaydeep PatilRank #205 · 11.7K reputationPosted Jun 29, 2024, 3:22 AM EDT
Hi,
Please refer the below steps,
1. Install MailChimp.Net NuGet package.
dotnet add package MailChimp.Net
2. Configure Mail champ client
using MailChimp.Net; using MailChimp.Net.Core; using MailChimp.Net.Models; using System.Threading.Tasks; public class MailchimpService { private readonly MailChimpManager _mailChimpManager; public MailchimpService(string apiKey) { _mailChimpManager = new MailChimpManager(apiKey); } public async Task AddSubscriberAsync(string listId, string email) { var member = new Member { EmailAddress = email, StatusIfNew = Status.Subscribed }; await _mailChimpManager.Members.AddOrUpdateAsync(listId, member); } }3. Register mail champ service in the startup
Note: you will get API key from mail champ website once you login.
public void ConfigureServices(IServiceCollection services) { services.AddSingleton(new MailchimpService("YOUR_MAILCHIMP_API_KEY")); }4. Inject mail champ service in the controller and use
using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; [ApiController] [Route("api/[controller]")] public class MailchimpController : ControllerBase { private readonly MailchimpService _mailchimpService; public MailchimpController(MailchimpService mailchimpService) { _mailchimpService = mailchimpService; } [HttpPost("subscribe")] public async Task Subscribe(string email) { await _mailchimpService.AddSubscriberAsync("YOUR_LIST_ID", email); return Ok("Subscribed successfully."); } }5. If you want to subscribe then use below code snipet.
[HttpPost("subscribe")] public async Task Subscribe(string email) { await _mailchimpService.AddSubscriberAsync("YOUR_LIST_ID", email); return Ok("Subscribed successfully."); }Jaimin ShethiyaRank #177 · 13.7K reputationPosted Jun 28, 2024, 6:48 AM EDT
Hello Sunny,
Please refer below links.
https://medium.com/@xavierpenya/mailchimp-using-dotnet-core-c-160cdb291f9a
https://www.codeindotnet.com/how-to-integrate-mailchimp-v3-0-api-in-dotnet-core-c/
Thanks