The transport failed to connect - Error Handling - TRY/CATCH

  • Thread starter Thread starter jason
  • Start date Start date
J

jason

I discovered this morning that a few of my sites have routines to
automatically email when pages are accessed. These pages were down
becuase the the smtp server I'm using was down. I would see a delay to
load the page for about 10 seconds followed by the :

The transport failed to connect error.

using the following code to email:

SmtpMail.Send(mail)

I added a try/catch, but now I still see the 10 second delay and
finally the page loads.

Try
SmtpMail.Send(mail)
Catch Exc As Exception
Finally
End Try

Question, Any way I can code the try/catch to give up much quicker on
the attempt to email.
 
Rather than giving up quicker, you might want to send the emails using an
asynchronous thread. This way the program execution wil not stop while the
emails are being sent.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
you might want to send the emails using an asynchronous thread.

sounds good. I coded the following , but it does not seem to execute
the sub. I found plenty of CS examples on threads in this group, but
none in VB.NET under ASP.NET. Looking for something quick and dirty,
if the thread dies, don't care to message anything, just continue
serving pages.


Sub Page_Load(Src as object, E as EventArgs )
Try
Dim t As New thread(Addressof eout)
t.start()
response.write("<br>trying")
Catch ex As exception
response.write("<br>failed")
End Try
end sub

Sub eout()
... email code that works by itself when smtp server is up
End Sub
 
Back
Top