get candidates mails return nothing with 6.5 BONITA VERSION

This groovy code bellow return nothing…
I’d like to obtain the email address list built from the code bellow (the obective is to send an email to all the people attached at the actor declared on the lane).
i found this code on the web but not sure it works.
i put this code into a groovy script at the receiver email address into email address connector.
Do you think that this code is sufficient ?
Thanks for your help !

//Get candidates mails (applying userFilter, portal restrictions & so on) in Bonita 6.5:

def emails = ;
def users;

def process_api = apiAccessor.getProcessAPI();
def identity_api = apiAccessor.getIdentityAPI();

def human_task_instance = process_api.getHumanTaskInstance(activityInstanceId);

def start_index = 0;
def max_results = 100;

while( users = process_api.getPossibleUsersOfPendingHumanTask(human_task_instance.getId(), start_index, max_results )) {
for( user in users ) {
try {
def pro_user = identity_api.getUserWithProfessionalDetails(user.getId());
def email = pro_user.getContactData().getEmail();
if( email != null ) {
emails.add( email );
}
}
catch( Exception e ) {
}
}
start_index += max_results;
}

emails.unique();
return emails.join( ‘,’ );apiAccessor