Query: i want to send bulk email at a time 2000 using asp.net core console application but smtp have limitation of 100 email at a time.
Please let me know if you have any idea
Query: i want to send bulk email at a time 2000 using asp.net core console application but smtp have limitation of 100 email at a time.
Please let me know if you have any idea
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
Amit MohantyRank #112 · 20K reputationPosted Aug 23, 2023, 7:07 AM EDT
You can be achieved this by breaking down your list of 2000 emails into smaller batches and then sending those batches using SMTP, or you might consider using third-party email delivery services like SendGrid, Amazon SES (Simple Email Service).
Mohammad HussainRank #513 · 4.8K reputationPosted Aug 23, 2023, 7:27 AM EDT
using System; using System.Collections.Generic; using SendGrid; using SendGrid.Helpers.Mail; using System.Threading.Tasks; class Program { static async Task Main(string[] args) { string sendGridApiKey = "your-sendgrid-api-key"; List recipients = new List { "[email protected]", "[email protected]", // ... add more recipients }; await SendBulkEmailAsync(recipients, sendGridApiKey); } static async Task SendBulkEmailAsync(List recipients, string apiKey) { var client = new SendGridClient(apiKey); var from = new EmailAddress("[email protected]", "Your Name"); var subject = "Your Subject"; var plainTextContent = "Your plain text content"; var htmlContent = "Your HTML content "; foreach (var recipient in recipients) { var to = new EmailAddress(recipient); var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = await client.SendEmailAsync(msg); Console.WriteLine($"Email sent to: {recipient}, Response: {response.StatusCode}"); } } }Cr BhargaviRank #420 · 5.9K reputationPosted Aug 23, 2023, 9:03 AM EDT
using System.Net; using System.Net.Mail; void SendEmailsUsingSmtp(List emails) { string smtpServer = "your.smtp.server"; int smtpPort = 587; // Update with your SMTP port string smtpUsername = "your.smtp.username"; string smtpPassword = "your.smtp.password"; using (SmtpClient client = new SmtpClient(smtpServer, smtpPort)) { client.Credentials = new NetworkCredential(smtpUsername, smtpPassword); client.EnableSsl = true; foreach (string email in emails) { using (MailMessage message = new MailMessage()) { message.From = new MailAddress("[email protected]"); message.To.Add(email); message.Subject = "Your Email Subject"; message.Body = "Your Email Body"; try { client.Send(message); Console.WriteLine($"Email sent to: {email}"); } catch (Exception ex) { Console.WriteLine($"Error sending email to {email}: {ex.Message}"); } } } } }