SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    objMail.Send error handling

    Hi,

    I was just wondering how I could handle errors from the email sending function. I ahave found that if the user fills in an email incorrectly which doesn't exist, an error is displayed and the email is not sent. I would like to stop the error appearing and instead, if an error occurs, change the objMail.To to a preset email and send their instead.

    Any help would be much appreciated, thanks.

  2. #2
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found the solution, thanks.

  3. #3
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TacMaf View Post
    Found the solution, thanks.
    Hi i have stumbled upon this post and need the same solution.

    Any chance you could help me out by posting yours?

    I have objMail.send that works fine if the email address is valid and works, however if it doesnt work i would like to simply tell it to output a more user friendly page explaining that the email was probably input incorrectly. Or forward the user back to the previous page carrying a message in a string in the url that i can then print onto the page they came from explaining the error, giving them the chance to easily retry.

    I know how to do the string message in the url etc in just dont know how to check success of the objMail.Send before the Asp page promptly outputs its own unfriendly error.

    Any help is much appreciated.

    Thanks a lot!

    Dan

  4. #4
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found the solution myself aswell, for anyone else that stumbles across this page i used:


    <! -- Place this at top of code -->
    <% on error resume next %>

    <your objmail.send code here>

    <!-- Then place this below the objmail.send line -->
    <%
    If Err.Number <> 0 Then
    Response.Write "Email Failure"
    Else
    Response.Write "Email Sent"
    End If
    %>


    Hope that helps anyone in the same position i was in

    Danny


Bookmarks

Posting Permissions

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