Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, December 16, 2018 
 
E-mail Address Validation  
Description:  In this article Thomas Aussem shows how to validate e-mail addresses in SalesLogix using VBScript and Regular Expressions. This article is a great source to get you up to speed on taking advantage of expressions to do data validation in the SalesLogix client.

Category:  SalesLogix VBScript Articles
Author:  Thomas Aussem
Submitted:  10/31/2005
   
Stats: 
Article has been read 20471 times

Rating: - 5.0 out of 5 by 8 users
 

fiogf49gjkf0d
E-mail Address Validation

In this article Thomas Aussem shows how to validate e-mail addresses in SalesLogix using VBScript and Regular Expressions. This article is a great source to get you up to speed on taking advantage of expressions to do data validation in the SalesLogix client.


Introduction

With storing e-mail addresses in the database and using them for mail merges, you will often find a lot of bounced e-mails from your campaign, because the syntax of the e-mail was not correct.

The purpose of this script is to validate the syntax of an e-mail address to ensure it is a valid e-mail address. You can run this script after entering an e-mail address, e.g. on the OnExitControl event of an Edit control.

To perform the validation check on the e-mail address, this script uses a regular expression, that checks the allowed characters in an e-mail address.

' check the syntax of an email address (TRUE/FALSE)
Function CheckEmailAddress(strEMail)
Dim objRegExp, iMatches, sPattern

    ' search pattern of valid email address:
    ' valid characters are: a-z, 0-9, ., -, _
    ' only one @-sign is allowed; minimum is one dot after @-sign, number of 
    ' characters after last dot is 2 chars, maximimum is 4 chars

    sPattern = "^[\w\.\-]+@([\w\-]+\.)*[\w\-]{2,63}\.[a-zA-Z]{2,4}$"

    ' leave function and return false when parameter is empty
    If len(trim(StrEMail)) = 0 Then
        CheckEmailAddress = False
        Exit Function
    End If

    ' generate new regular expression
    Set objRegExp = New RegExp
    objRegExp.Pattern = sPattern
    objRegExp.IgnoreCase = True
    Set iMatches = objRegExp.Execute(strEMail)

    If iMatches.Count = 1 Then
        CheckEmailAddress = True
    Else
        CheckEmailAddress = False
    End If

    Set objRegExp = Nothing
    
End Function


This script will work with any version of SalesLogix 6.x, since it uses only VBScript and Regular Expression, which are available from any version SalesLogix script.

 

About the Author

  Thomas Aussem
openCRMS

fiogf49gjkf0d

Working with SalesLogix 6.2 since December 2004 You'll find my German blog (that deals with SalesLogix, SQL Server and web development) on http://www.opencrms.de



View online profile for Thomas Aussem
 

[ back to top] [ send to a friend]  

Rate This Article you must log-in to rate articles. [login here] 
 
Please log in to rate article.
 

Comments & Discussion you must log-in to add comments. [login here] 
 
Author Article Comments and Discussion
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Re: E-mail Address Validation
Posted: 10/31/2005 4:54:15 PM
fiogf49gjkf0d
Thomas,

Excellent use, and example, of using Regular Expressions in SalesLogix. Great article.

-Ryan
 
RJ Eaton



Re: E-mail Address Validation
Posted: 10/24/2006 10:44:28 AM
fiogf49gjkf0d
Thomas, Thanks so much you saved me a few hours of coding by adding this to some various places for checks.. !! Great Artical
 
RJ Eaton



Re: E-mail Address Validation
Posted: 2/2/2007 10:18:50 AM
fiogf49gjkf0d
Thomas,
I seem to be catching an e-mail address as a bad address that is containing an underscore such as "firstname_lastname@place.place.gov"

In your example above which part of the pattern is responsible for the underscore being accepted.. I can trackout the a-z however what does the rest of the pattern line mean..

Thanks
 
Thomas Aussem



Re: E-mail Address Validation
Posted: 2/5/2007 8:41:14 AM
fiogf49gjkf0d
change the pattern into

sPattern = "^[\w\.\-\_]+@([\w\-]+\.)*[\w\-]{2,63}\.[a-zA-Z]{2,4}$"

and it should work!

Best regards,
Thomas
 
Matthew
 

Re: E-mail Address Validation
Posted: 8/14/2008 10:58:23 AM
fiogf49gjkf0d
Can you give an example of how you tie that into the onexit control?
 
Thomas Aussem



Re: E-mail Address Validation
Posted: 8/14/2008 12:49:56 PM
fiogf49gjkf0d
Hi Matthew,

An example:

- Open "Contact Detail" in Architect, select email field "lnkEMail" and edit the OnExitControl event
- Add the following code:

Sub lnkEmailExitControl(Sender)
If Not CheckEmailAddress(trim(lnkEmail.Text)) then
MsgBox "Wrong E-Mail syntax! Please choose another email address!"
lnkEmail.SetFocus
end if
End Sub

Cheers,
Thomas
 
Matthew
 

Re: E-mail Address Validation
Posted: 8/14/2008 3:08:17 PM
fiogf49gjkf0d
This is a lifesaver. Thank you Thomas!
 
Matthew
 

Re: E-mail Address Validation
Posted: 8/20/2008 11:09:14 AM
fiogf49gjkf0d
This works great. I am going to look at adjusted this to validate on exit of any contact record, not just the field. This will help force at least the invalid addresses that people have entered, even if they are not good contact emails. (i.e. people entering web addresses and other nonemail entries).
 
 

       Visit the slxdeveloper.com Community Forums!
Not finding the information you need here? Try the forums! Get help from others in the community, share your expertise, get what you need from the slxdeveloper.com community. Go to the forums...
 



 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2018 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 12/16/2018 3:55:51 PM