1

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?

Curtis
  • 101,612
  • 66
  • 270
  • 352

1 Answers1

1

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

Saif Khan
  • 18,402
  • 29
  • 102
  • 147
  • About 700 emails were sent. If the error was related to SMTP restrictions, surely the error would be different to a timeout expired error? – Curtis Jun 01 '11 at 08:08
  • I don't think your thread would timeout just like that. You got something going on in the SendMails() function or your SMTP is throttled. – Saif Khan Jun 01 '11 at 20:03
  • What if the background thread had been running for 6 hours for example? Do background threads not timeout like regular processes? Sorry, I don't know a great in-depth deal about how servers deal with background threads – Curtis Jun 02 '11 at 08:12