How can i limit the number of mails sent using SmtpClient (System.Net.Mail) per minute in asp.net?
I've a requirement to send more than 20000 alert mails at one click and wanted to limit the number of mails sent per minute.
Is there any inbuilt/alternate way that can be used along with SmtpClient t开发者_高级运维o do this other than giving a System.Thread.Sleep(1000) after each sent?
Does the System.Thread.Sleep(1000) helps to overcome the limited number connections a mail server can handle simultaneously?
I think you are on right track.
By default SMTPclient is not providing any way to limit mail sent per minute. So, using sleep is the one way to do that.
To make your application responsive you can use threading.
I'd recommend queuing them up in MSMQ and letting another process do that work, then your application can let the user know they're being sent or whatever needs to happen.
精彩评论