Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any way to know if email is valid?
Message
De
01/02/2006 16:49:43
 
 
À
01/02/2006 16:18:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
01092572
Message ID:
01092604
Vues:
24
This message has been marked as a message which has helped to the initial question of the thread.
>The database contains many email adresses. Some of those adresses are old others are recent.
>
>Is there a way to test for the validity of an address before sending a message to that address?

I include here some VFP code to check for basic validations. However, there is no way to know if an email exists before sending it.
* Call all validation methods
LOCAL lnLocation

* As this is a global object, we need to reset all properties at call time
This.cValidationMessage=''

* The email cannot be blank
IF LEN(ALLTRIM(This.cEmail))=0
   This.nErrorValidation=8
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* No dot
IF AT('.',This.cEmail)=0
   This.nErrorValidation=9
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* No @
IF AT('@',This.cEmail)=0
   This.nErrorValidation=10
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* We can't accept an email starting with @
IF This.cEmail='@'
   This.nErrorValidation=11
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* The last character cannot be a dot
IF SUBSTR(This.cEmail,LEN(This.cEmail),1)='.'
   This.nErrorValidation=12
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* If we have more than one @
IF OCCURS('@',This.cEmail)>1
   This.nErrorValidation=13
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* No space
IF AT(' ',This.cEmail)>0
   This.nErrorValidation=14
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* No comma
IF AT(',',This.cEmail)>0
   This.nErrorValidation=15
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* Bad character
IF INLIST(UPPER(This.cEmail),'SPAM','NOSPAM')
   This.nErrorValidation=16
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* We need to have at least 5 characters
IF LEN(This.cEmail)<5
   This.nErrorValidation=17
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* After the last dot, we can't have a number
IF VAL(SUBSTR(This.cEmail,AT('.',This.cEmail,OCCUR('.',This.cEmail))+1))>0
   This.nErrorValidation=18
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* We can't have a dot immediately after the @
lnLocation=AT('@',This.cEmail)
IF SUBSTR(This.cEmail,lnLocation+1,1)='.'
   This.nErrorValidation=19
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF

* We can't have a semi-colon
lnLocation=AT(';',This.cEmail)
IF lnLocation>0
   This.nErrorValidation=20
   This.cValidationMessage=This.ReturnMessage()
   RETURN .F.
ENDIF
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform