By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

<ja***@cyberpine.com> wrote in message
news:ef*************************@posting.google.co m...
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.

Nov 18 '05 #2

P: n/a
"Kevin Spencer" <ke***@takempis.com> wrote in message news:<uJ**************@TK2MSFTNGP11.phx.gbl>...
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
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.