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

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.
 
K

Kevin Spencer

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.
 
J

jason

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top