|
Here's some tests that seem to cover most of the bases for us The list was compiled mostly by running into real email addresses in our Database which caused the QtmmSendMail API to choke: C Eval W#VALID = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcd C fghijklmnopqrstuvwxyz123456789 C .@-_' ***Invalid Characters in address(includes blanks). C IF %Check(W#VALID:(%Trim(EMAIL))) > 0 C RETURN C ENDIF ***No '@' in address. C IF %Scan('@':EMAIL) = 0 C RETURN C ENDIF *** '.' is first character C IF %Scan('.':EMAIL) = 1 C RETURN C ENDIF *** '@' is first character C IF %Scan('@':EMAIL) = 1 C RETURN C ENDIF ***More than one '@' in address C Eval W#POS = %Scan('@':EMAIL) C IF %Scan('@':EMAIL:(W#POS+1)) > 0 C RETURN C ENDIF ** No . after the @ C If %Scan('.':EMAIL:W#POS) = 0 C RETURN C ENDIF ** "@-" or "-@" or "-." or ".-" etc ** don't need '@@' because it was covered above C If %Scan('@-':EMAIL) > 0 C or %Scan('@_':EMAIL) > 0 C or %Scan('@.':EMAIL) > 0 C or %Scan('-@':EMAIL) > 0 C or %Scan('--':EMAIL) > 0 C or %Scan('-_':EMAIL) > 0 C or %Scan('-.':EMAIL) > 0 C or %Scan('.-':EMAIL) > 0 C or %Scan('._':EMAIL) > 0 C or %Scan('.@':EMAIL) > 0 C or %Scan('..':EMAIL) > 0 C or %Scan('_.':EMAIL) > 0 C or %Scan('_@':EMAIL) > 0 C or %Scan('__':EMAIL) > 0 C or %Scan('_-':EMAIL) > 0 C Return C EndIF ** . at the end of the address C If %Subst(EMAIL:(%Len(%Trim(EMAIL))):1) = C '.' C RETURN C ENDIF >-----Original Message----- >From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] >On Behalf Of Bob Voltz >Sent: Monday, November 28, 2005 9:36 AM >To: RPG400-L@xxxxxxxxxxxx >Subject: EMAIL Syntax Validation > > > Does anyone have an email syntax validation routine they could post...or >point me to a sample somewhere? I just want to make sure it is in a valid >format. I don't care if it is a valid address or if the domain exists. >Oh....it also has to be in RPG III.....don't ask..... > > Thanks, > Bob Voltz > >-- >This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list >To post a message email: RPG400-L@xxxxxxxxxxxx >To subscribe, unsubscribe, or change list options, >visit: http://lists.midrange.com/mailman/listinfo/rpg400-l >or email: RPG400-L-request@xxxxxxxxxxxx >Before posting, please take a moment to review the archives >at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.