I have the following portion of code on a Click Event on my page:
Dim ts As New ThreadStart(AddressOf SendEmails)
Dim t As New Thread(ts)
t.IsBackground = True
t.Start()
This actions the SendEmails
method which sends out 1000s of newsletter emails.
However, it seems this is timing out, as I've been able to log the following error:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
How can I increase the timeout amount to allow time to send 1000s of emails?
Showing some code in the "SendEmails" function will be helpful. The timeout is probably happening at SMTP level...looking at the error message, it could also be that the server has closed the SMTP connection. Knowing what Email server you are connecting to will also be helpful. If it's an Exchange Server, the admin probably has some restriction on the SMTP connector as to how musch emails can be sent via one connection and that's what's might be the problem. Are you able to send around 10 or 50 emails...or any email at all?
On another note - try using the BackgroundWorker