Send Multiple email adresses with hb_SendMail

HMG Samples and Enhancements

Moderator: Rathinagiri

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

Send Multiple email adresses with hb_SendMail

Post by WimS »

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

Maybe it is useful for someone?

Kind Regards,

Wim S

FUNCTION Email_adress_validation
PARAMETERS adress_string
LOCAL string_counter , array_counter
LOCAL adress_array := {}
string_counter = 1
array_counter = 1
adress_array[1] = ""
FOR string_counter = 1 TO LEN(adress_string)
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
adress_array[array_counter] := ""
CASE UPPER(SUBSTR(adress_string,string_counter,1)) $ " "
* no action
MsgInfo("Email adress contains illegal character: " +SUBSTR(adress_string,string_counter,1))
string_counter := LEN(adress_string)
array_counter := 0
NEXT teller
RETURN(if(array_counter = 0,"",adress_array))

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 »

Gracias Wim S por compartir,


Posts: 672
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 68 times

Post by EduardoLuis »

Gracias por compartir
Thanks for share.

Posts: 143
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela
Been thanked: 14 times


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

Thanks for sharing your hard work and dedication ..

User avatar
Posts: 2772
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
Location: Belgium
Has thanked: 1071 times
Been thanked: 193 times

Post by serge_girard »


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^ is a valid emailaddres but something@x^ is NOT valid.
4) Some chars are not allowed as first char and some are not allowed as last char.... is NOT allowed nor is

Best way is to split an emailaddress into 4 parts and then check each part:
- localpart
- @
- domainpart
- extension" onclick=";return false; gives a little information about this subject but is not complete!

Greetings, Serge/Belgium
Serge Now Is The Happiest Time Of Your Life !

Post Reply