I am implementing some multiple email sending application with Csharp.
Basically I am just sending 100 emails in three different threads with indepent smtp parameters. Emails can be sent at the same time in the three different threads.
This simple code works for now in Sandbox application.
However, many articles mentioned that sending emails is I/O bounded process.
I am afraid that one thread can cause the other thread failure while one smtp is connected to the port 25.
Fortunaltey, so far, just using this simple multiple threads model does not catch the I/O exception like this while sending 100 emails.
.net - Intermittent System.IO.IOException while using SmtpClient - Stack Overflow[
^]
However, it is only sand box application and this code might carry serious problem in real world application which is not verified at the moment.
Does anyone recommend using ThreadPool.QueueUserWorkItem Method or seeing value of using ThreadPool.QueueUserWorkItem Method in this application to be absoulte safe ?
ThreadPool.QueueUserWorkItem Method (System.Threading) | Microsoft Docs[
^]
Or is it sufficiently safe to use this simple threads model ?
Kind regards.
What I have tried:
Thread td1 = new Thread(SendManyEmails);
Thread td2 = new Thread(SendManyEmails);
Thread td3 = new Thread(SendManyEmails);