You could also just look at iw_send_email.ipl although that script is not without its problems. Just see how the "to" list is compiled and also look at task_output xml from the email task.
!