www.webdeveloper.com
Results 1 to 3 of 3

Thread: Exception handling with CDO.message

  1. #1
    Join Date
    Oct 2005
    Posts
    32

    Exception handling with CDO.message

    Hi,

    I am using code based on the following to send an email from a form on my site. One to me, and a confrmation email to the customer.

    <%
    theSchema="http://schemas.microsoft.com/cdo/configuration"
    set cdoConfig=server.CreateObject("CDO.configuration")
    cdoConfig.fields.item(theSchema & "sendusing")=2
    cdoConfig.fields.item(theSchema & "smtpserver")="my.smtp.server"
    cdoConfig.fields.update

    set cdoMessage=server.createObject("cdo.message")
    cdoMessage.configuration=cdoConfig
    cdoMessage.from=request.form("email")
    cdoMessage.to=request.form("to")
    cdoMessage.subject=request.form("subject")
    cdoMessage.textbody=request.form("message")
    cdoMessage.send

    set cdoConfig=nothing
    set cdoMessage=nothing

    %>



    The problem is, that if the customer enters an incorrect email address, the site displays an error message.

    I have an error page set up, informing the customer that their message couldn't be sent, and directing them back to check their email address, but how do I get it to divert to this page, rather than throwing an unhelpful error message?

    Any help would be gratefully appreciated.

    Thanks,

    Adam

  2. #2
    Join Date
    Nov 2005
    Posts
    47
    Before the cdoMessage.send line add the following:
    Code:
    On Error Resume Next
    then after the cdoMessage.send line add the following:
    Code:
    	If Err.Number <> 0 Then
    		Response.Redirect("ErrorPage.asp")
    	end if
    You may want to check the error number to be sure that the e-mail address was the problem.

  3. #3
    Join Date
    Oct 2005
    Posts
    32
    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles