Sending a large number of emails with C# SmtpClient

I have an application which will need to send emails to users on a company intranet. In the past the application has sent a handful of emails for various reasons, either from the web application or a windows service and it has worked fine. This new application will occasionally need to send as many as 40,000 emails at once (literally one to every employee). They must be separate emails because the content is customized per user. At first I naively thought that I'd be able to iterate over the list of users and fire the emails of consecutively. While I haven't yet tested it at this scale, I feel like this is a bad idea.

Any ideas on how to handle this? An email service that wakes up and runs every so often and sends some number emails? If so, what do you think a good max to try at once is? All the emails will be sent to the same exchange server, so I'm worried about taxing resources on both sending and receiving.

Anyway just wondering how others have solved this problem.

by KuchDaddy via /r/csharp

Leave a Reply