You should use some REXX script to do what you want. We can perhaps post our partial solutions (functions) here to each task that has to be handled to create the e-mail(s).
Can we assume that the file ( clients.txt ) look like?
12345{TAB}John Doe{TAB}john.doe@gmail.com
67890{TAB}Jane Doe{TAB}jane.doe@gmail.com
13579{TAB}Joe Doe{TAB}joe.doe@gmail.com
24680{TAB}Jill Doe{TAB}jill.doe@gmail.com
Let's begin with some of the code for you all to add your suggestions to.
/* Script to send PDF-files to clients */
path = 'C:\invoices'
client_email = 'C:\invoices\clients.txt'
/* Load RexxUtil Library */
IF RxFuncQuery( 'SysLoadFuncs' ) THEN
DO
CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
CALL SysLoadFuncs
END
/* Find the files to send */
IF( SysFileTree( path'\CLIENT*.PDF', 'filename.', 'FO' ) THEN
DO i = 1 TO filename.0 /* Go through each found filename */
PARSE UPPER VALUE filename.i WITH 'CLIENT'clientno'INVOICE'invoiceno'.'extension
/* Find the email address based on client number (clientno) */
/* ... add the call to function here (instead of this comment) ... */
/* Create the e-mail with PMMSend */
/* ... add the call to function here (instead of this comment) ... */
END
RETURN rc
/* Find the email address based on client number (clientno) */
/* ... and write the actual function here (instead of this comment) ... */
/* Create the e-mail with PMMSend */
/* ... and write the actual function here (instead of this comment) ... */