Jacques Bronkhorst
Jacques Bronkhorst

Reputation: 1695

Best Way to handle Bulk Mail in C#

What would be the best method to send bulk emails to certain lists. E.g. a user would request a service from a service category. I get 200-20000 matching emails for the users criteria and send the users request to the recipients.

I have done some research but not sure which would be the best solution for the task.

Method 1, use multiple threads to enable multiple SMTP clients to send mails (not sure if I send it to a massive amount of recipients if it would kill the server with all the threads) http://www.aspsnippets.com/Articles/Send-Bulk-Mass-Email-in-ASPNet-using-C-and-VBNet.aspx

Method 2, use service like sendgrid to manage the emails. (I see that in the marketing campaigns you can manage lists/contacts. Just not sure if you can dynamically generate the content for a template and send to the certain list) https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html

Any advice will be greatly appreciated!!

Upvotes: 4

Views: 2136

Answers (1)

Monah
Monah

Reputation: 6784

You have many different ways

The first way, which we use it and in my opinion is the best, but you need to use a database to store the data and to write some code to be executed:

  1. Create a table "EmailLogs" with the following fields

ProfileName, Body, Subject, [To],CC,BCC,IsActive,QueuedOn,SentOn

  1. Write a Stored Procedure ClearEmailLogs to send top 50 where IsActive=1 and update the SentOn by getdate() value
  2. Write a Job in SQL server to execute each 10 minutes
  3. From your application, you just need to insert the bulk of messages to the table EmailLogs

ProfileName: maybe you need to have many emails configuration to send through different emails for example [email protected] or [email protected], in SQL server you can create profile for each email you want to use

Why to send max 50 email each 10 minutes? because if you will send frequently emails to recipients, other companies like yahoo or google...etc might block your emails and send them to the spam or junk mails.

second way, you can subscribe to some services, you can find online, but you need to pay some money for this service.

Hope this will helped you

Upvotes: 2

Related Questions