Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error checking with CDONTS.NEWMAIL

Status
Not open for further replies.

mellenburg

Programmer
Aug 27, 2001
77
US
I'm using CDONTS.NEWMAIL to automatically send an email once a form has been submitted. I would like check to see if the message was successfully sent, and then display a message to the user telling them the message was successfully sent.

One way that CDONTS doesn't send mail is if the FROM field has a space in it (eg. John Doe). I don't know how many such cases there are and don't want the user thinking the email was sent when it wasnt.
 
I dont believe you can get any confirmation that the email was deilvered OK but you can perform some validation on the various email addresses before you send the email.

CDONTS won't send the email at all if the FROM address is invalid (including having a space). You could maybe write a small function to validate the .to and .from email addresses (.cc and .bcc also if you are using them).

This validation could be done either client-side (see Javascript forum for an example - Forum216) or server-side or both just to be sure.

Below is an example of some server-side validation you could try from Thread333-50123. You could also look at using Regular Expressions (RegExp) to do this (more elegant but harder to get your head around)
Code:
function checkEmail()
        
        dim strMsg,strDot,strAt,strEmail
        strDot="."
        strAt="@"
        strEmail=txtEmail.value
        strMsg=""
        if (Instr(strEmail,strAt)=0) or ((left((right(strEmail,4)),1)) <> strDot )then
            strMsg="Email is invalid "
        end if
        checkEmail=strMsg
        
    end function

Tony
________________________________________________________________________________
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top