length userid $ 12;
dsid=open('my.employee');
vnum=varnum(dsid,'userid');
call execcmd('prtfile "my-print-file"');

do while(fetch(dsid) ne -1);
   userid=getvarc(dsid,vnum);
   call letter('lib.cat.my.letter','print',
               'my.employee(where=(userid='||
               quote(userid)||'))');
   rc=system("mail send "||userid||
      " subject('subject text') from ('my-print-file')");
end;

rc=close(dsid);