Send Multiple email adresses with hb_SendMail

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
User avatar
WimS
Posts: 5
Joined: Fri Feb 14, 2014 8:47 pm
Location: The Netherlands
Contact:

Send Multiple email adresses with hb_SendMail

Post by WimS » Fri Mar 21, 2014 9:11 pm

Hi HMG people,

I made a generic small and simple function to fill in email-adresses in the usual way (with ...; ....; ...) and
convert it to an array.
It can be used in combination with hb_SendMail.
The parameters To, CC or BCC can first be send to this routine with
email_adress_validation(To_variable)

Maybe it is useful for someone?

Kind Regards,

Wim S


*-----EMAIL_ADRESS_VALIDATION-----
FUNCTION Email_adress_validation
PARAMETERS adress_string
LOCAL string_counter , array_counter
LOCAL adress_array := {}
string_counter = 1
array_counter = 1
AADD(adress_array,1)
adress_array[1] = ""
FOR string_counter = 1 TO LEN(adress_string)
DO CASE
CASE UPPER(SUBSTR(adress_string,string_counter,1)) $ "ABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890-.@"
adress_array[array_counter] := adress_array[array_counter] + SUBSTR(adress_string,string_counter,1)
CASE UPPER(SUBSTR(adress_string,string_counter,1)) $ ";,"
array_counter := array_counter + 1
AADD(adress_array,array_counter)
adress_array[array_counter] := ""
CASE UPPER(SUBSTR(adress_string,string_counter,1)) $ " "
* no action
OTHERWISE
MsgInfo("Email adress contains illegal character: " +SUBSTR(adress_string,string_counter,1))
string_counter := LEN(adress_string)
array_counter := 0
ENDCASE
NEXT teller
RETURN(if(array_counter = 0,"",adress_array))
*-----EOF-EMAIL_ADRESS_VALIDATION-----

Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México
Has thanked: 1 time
Been thanked: 2 times

Post by Javier Tovar » Fri Mar 21, 2014 9:39 pm

Gracias Wim S por compartir,

Saludos

EduardoLuis
Posts: 655
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 61 times

Post by EduardoLuis » Fri Mar 21, 2014 10:08 pm

Gracias por compartir
Thanks for share.

ASESORMIX
Posts: 110
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela
Been thanked: 6 times

Post by ASESORMIX » Sat Mar 22, 2014 10:56 am

Gracias por compartir tu esfuerzo y dedicación...

Thanks for sharing your hard work and dedication ..

User avatar
serge_girard
Posts: 2361
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 612 times
Been thanked: 124 times
Contact:

Post by serge_girard » Mon Mar 24, 2014 10:40 am

Wim,

Thanks for sharing!

I was already looking for an emailaddress-test-routine.

Regretfully there are some lacks:

1) It doesn't allow addresses with 'strange' chars: eg: FRANçOIS@SOMETHING.COM
2) It accepts addresses like: FRANK@SOMETHING;COM (;) FRANK@SOMETHING (without dot and without extension)
3) Some 'strange' chars are allowed in the first part (localpart) and most 'strange' chars are NOT allowed in the domainpart: x^x@something.uk is a valid emailaddres but something@x^x.uk is NOT valid.
4) Some chars are not allowed as first char and some are not allowed as last char.... .sg@something.uk is NOT allowed nor is sg@something.uk.

Best way is to split an emailaddress into 4 parts and then check each part:
- localpart
- @
- domainpart
- extension

http://en.wikipedia.org/wiki/Email_address" onclick="window.open(this.href);return false; gives a little information about this subject but is not complete!


Greetings, Serge/Belgium

Post Reply