|
This is what I use, it is a bit dated, but catches most mistakes:
0025.00 emailaux = %trim(n_email);
0026.00 if %scan('@': emailaux) = *zero;
0027.00 msgDta = 'Al correo le falta el "@"';
0028.00 endif;
0029.00
0030.00 if %scan('.@': emailaux) > *zero;
0031.00 msgDta = 'El correo tiene el nombre incorrecto';
0032.00 endif;
0033.00
0034.00 if %scan('@.': emailaux) > *zero;
0035.00 msgDta = 'El correo tiene el Dominio incorrecto';
0036.00 endif;
0037.00
0038.00 if %subst(emailaux: 1: 1) = '@' or %subst(emailaux: 1: 1) = '.' or
0039.00 %subst(emailaux: 1: 1) = '-';
0040.00 msgDta = 'El correo empieza con caracter incorrecto';
0041.00 endif;
0042.00
0043.00 if %subst(emailaux: %len(emailaux)) = '@' or
0044.00 %subst(emailaux: %len(emailaux)) = '.' or
0045.00 %subst(emailaux: %len(emailaux)) = '-';
0046.00 msgDta = 'El correo termina con caracter incorrecto';
0047.00 endif;
0048.00
0049.00 emailaux = %xlate(
0050.00 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-
0123456789':
0051.00 '
* ':
0052.00 emailaux);
0053.00
0054.00 if msgDta = *blank and %trim(emailaux) <> '@';
0055.00 msgDta = 'El correo tiene algun error';
0056.00 endif;
0057.00
0058.00 if msgDta <> *blank;
0059.00 SendEscMsg ('CPF9898': 'QCPFMSG QSYS': MsgDta: %len(MsgDta):
0060.00 '*ESCAPE': '*': 2: MsgKey: ErrorDS);
0061.00 endif;
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 mailing list archive is Copyright 1997-2026 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.