Send Multiple email adresses with hb_SendMail
Posted: 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-----
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-----