How to use an e-mail address contained in a MySQL table

De MappingDoc

This article relates to MapOut (MapCom) 5.2 and higher and MapDraw 6.0 and higher

This article shows how to use e-mail addresses contained in a MySQL table to e-mail mapped spooled files automatically to dynamic addresses. You will need a database table with a list of names found in the spooled file under the heading NAME for example and for each name the e-mail address(es) to which the files will be sent under the heading EMAIL for example.

In MapDraw, the document template must have the 3 following zones to handle the distribution of the e-mail:

1. NAME : Memory / Text Memory zone containing the name grabbed from the spooled file

2. EMAIL : Memory / SQL Memory zone. Add the following SQL command in the 'Characters added after the zone' field: {SQL SELECT EMAIL FROM TEST.USER WHERE NAME="[[NAME]]"}. This zone queries the database and retrieves the value of the EMAIL field based on the NAME. The NAME zone is used to filter the line we're interested in.

3. MAPSND : Archive / MapSend zone. MapCom sends an e-mail to the address(es) stipulated in MapDraw using the MAPSND zone. Here you don't grab the value directly from the spooled file but you want to use the value returned by the EMAIL SQL zone. So in the MAPSND zone, you need to use the value EMAIL [[EMAIL]] in the 'Characters added after the zone' field.

Then, generate the project and import it as you would normally do. From now on, whenever the spooled file is processed with this template, a query will be made to the database to determine which e-mail address to use.

It would worl exactly the same way on iSeries, the only difference being that on iSeries we're dealing with Physical Files and not Database Tables. The database on the iSeries would be the Library and the table would be the Physical File.