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

Discussion in 'ASP .Net' started by jason@cyberpine.com, Feb 2, 2004.

  1. Guest

    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.
    , Feb 2, 2004
    #1
    1. Advertising

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

    <> wrote in message
    news:...
    > 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.
    Kevin Spencer, Feb 2, 2004
    #2
    1. Advertising

  3. Guest

    "Kevin Spencer" <> wrote in message news:<uJE$>...
    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
    , Feb 3, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Lankford
    Replies:
    14
    Views:
    21,074
    naveenkumarmandava
    Jul 16, 2008
  2. Lori McDonald
    Replies:
    0
    Views:
    5,735
    Lori McDonald
    Feb 16, 2004
  3. Sudhan
    Replies:
    1
    Views:
    7,728
    Teemu Keiski
    Dec 20, 2005
  4. Hawksey
    Replies:
    1
    Views:
    901
    rajanand_m
    Nov 6, 2009
  5. Nathan Sokalski
    Replies:
    5
    Views:
    592
    Ricky Yau
    Dec 11, 2006
Loading...

Share This Page