Q: E-mail distribution: Extract E-mail address from spooled file or Database

Question:
I know, that I manully can insert E-mail addresses of all customers in spooled files in the InterForm400 database, but I have one of these situations:

a) Every page of the merged spooled file contains the E-mail address for the customer.

b) I do not want to manually type in all of the E-mail addresses of our customers. I want InterForm400 to do a lookup in an exsisting database.

How do I do that?

Answer:
For both cases you should use a user exit program and specify it in '1.Key definition' of the E-mail finishing function..

An example of a user exit program can be found member, MAILEXIT in source file APF3812/APISRC.

These are the ways to solve the tasks:

a) Create a key in the E-mail finishing function, that contains the E-mail address. This key is transfered to the user exit program as &ENTRYKEY1. Move this parameter into the returned mail address, &RTNTOADR as below.

CHGVAR     VAR(&RTNTOADR) VALUE(&ENTRYKEY1)
CHGVAR     VAR(&RTNTXTFMT) VALUE('<Text version>')    

Exchange <Text version> with the Text version defined in option '4.Definition E-mail text' of the finishing function, that you want to use for this E-mail address.

Insert the two lines above as the last two lines before ENDPGM and compile the program to another library than APF3812.


b) Create one or more keys in the E-mail finishing function, that contains the customer identifications. Make a program based on member, MAILEXIT in sourcefile, APF3812/APISRC.

Insert a look-up in your database based on the transfered keys, &ENTRYKEY1-3 and return both the E-mail address to send to and the text version to use as above.


TIP: Look at the source, MAILEXIT in APF3812/APISRC for all of the other parameters you can specify in the user exit program.