I have a asp.net program, and I need to send a lot of emails.
when i call http://localhost:70/sendemails
system will send the emails one by one in seperated threads(just like async).
I don’t know if this is the best method.
but what i want to know is: I schedule to send 10000 emails, and after i call the link, and then close the browser(means that the session will be closed too),
Then if the threads i created will also be terminated ?
What is the best method to send lots of emails ?
I would suggest that the ASP.NET application writes the information into a queue of some description – whether that’s a message queue or just a table in the database.
Then have a separate service running to process the queue and send the emails. That way you don’t need to wait until the emails have been sent before you respond, but you can still be sure that by the time the page responds, the request has been persisted.
Another alternative would just be to start a new thread to do the email sending within the ASP.NET application, but that means that if the application were to fall over (or be recycled) the request would be lost. It’s easier to put the persistence and fault tolerance in a separate service, IMO.