Please enable JavaScript to view this site.

Scenario

You wish to send a document, designed using the Cobwebb Designer, to multiple email addresses as individual emails, but you have no idea how many addresses may be required for each document. This is not achievable using the power of the Cobwebb Designer alone.

Solution

From version 6.2.87

Step 1 - First Cobwebb Design

Create a Cobwebb Design over your spooled file using the Advanced Reformatting Utility (ADVRFMT). This doesn't have to be a complicated design just outputting *HDR and *DET lines from the spooled file.

As the ADVRFMT does not need the Output pane in the Cobwebb Designer, you can use this to write the email details for each document to be output as a .TXT file - please see the topic The .TXT file for details. If you are splitting your document on say Invoice number, then you will have a separate .TXT file for each invoice, perhaps using the invoice number as the file name. When writing the information for your .TXT file output:

First write the email details that are not going to change for each email to the .TXT file such as Subject, Email From etc.

Next extract the recipient email details for your output, either from the spooled file or by using an Exit program, and write them to the .TXT file.

Add a File Output Device to write this information to a folder on the IBM i giving the .TXT file the same name as you are going to give the .PDF file in the second Cobwebb Design.

Step 2 - Second Cobwebb Design

This Cobwebb Design is created over the ADVRFMT output from your first design. Design the PDF output as required and write the .PDF to the same folder as the .TXT file with the same name just a different file extension i.e. PDF.

Example File names: INV001.TXT and INV001.PDF

Step 3 - FMEMAIL Folder Monitor

Configure a Folder Monitor, as a *STD Monitor Type, over the folder where you have written your .TXT and .PDF files. Specify the Program to call as FMEMAIL and add a filter for files with a .PDF extension. In this way you can be sure that both files will exist when the program runs as the .TXT file is written by the 1st PPD.

FMEMAIL Folder Monitor

FMEMAIL Filter

Once the program finds a PDF file it looks for a file of exactly the same name (case sensitive) with a .TXT extension. It then reads this file, extracting all the email details for sending out the PDF file as an attachment.

Once the email details have been gathered, the program calls our SMTP Client (POSTIE3) to send the email(s) directly to the SMTP Mail Server, without putting them on the Cobwebb Queue. If there is an error then a message is written to the joblog for the Folder Monitor and the .TXT & PDF files are both moved to the failed folder configured for the Folder Monitor.

Notes:

1.If you don’t want to use the .TXT extension then change PARM1 for the Folder Monitor and enter the extension required without the dot e.g. “IDX”.

2.Switching on Trace Mode (U8) for the Folder Monitor job running in the CPPD subsystem will write all the information extracted from the .TXT file to the joblog. This can help if you need to debug your output.

3.Switching on Test Mode (U7) for the Folder Monitor job running in the CPPD subsystem will run the program but not call POSTIE3 i.e. no email will be sent.