Please enable JavaScript to view this site.

A-Shell Reference

Navigation: Subroutines > EMAILX > EMAILX Scenarios

Emailing Reports to Lists

Scroll Prev Top Next More

Added May 2017

When emailing capability is introduced into an existing environment, a common user request is to add an email option to several existing report programs, with the possibility of a common or different distribution lists for each report. To accomplish this with minimal programming effort, you may find the utility package EMXREP in EXLIB: [909,30] helpful. The package consists of a standalone program, EMXREP.BP, for maintaining a cross-reference grid of email addresses and reports, plus an include file, emxrep.bsi, containing a high level function, Fn'EMX'Send'Rep(), that reduces the task down to a single function call.

The EMXREP maintenance program appears as follows:

ashref_img167

The idea is to add all of the email addresses to the first column (using the "Add Addr") button as needed, and add columns for each of the reports you want to email (using the Add Report button). Then to include a particular email address in the distribution list for a particular report, just check the corresponding box in the grid. Each row indicates all of the reports to be emailed to that address, and each column represents the distribution list for that report. You can sort and rearrange the columns to make it easier to handle as the number of addresses and reports gets large.

The report names can be arbitrary, but typically using the name of the program that generates the report is the simplest approach.

To send the report to the distribution list, just insert the following call into the program after the report file is closed (typically just before or after spooling it), e.g.

++include emailx:emxrep.bsi    

 

open #ch, REPORT$, output

<create report>

close #ch

 

EMX'STATUS = Fn'EMX'Send'Rep(repfile$=REPORT$, &

             from$="admin@yourdomain.com", &

             subject$="Sample Report")

 

Note that the Fn'EMX'Send'Rep() function uses named parameters, so you must compil with the /P (or /PX) switch, and there are several additional optional parameters which you can specify to modify the default behavior. In the default case, it simply wraps the report in a fixed pitch HTML envelope and strips any control characters found at the start of text lines. This simple approach works well for short plain text reports, eliminating the need for attachments, viewers, etc. In GUI environments, it displays a progress/abort dialog during the sending process, and a completion dialog with the success or failure information. The success dialog uses the enhanced MSGBOX time-out capability introduced in A-Shell version 6.4 which does not require user intervention, whereas the failure dialog waits for an acknowledgment.

See the EMXREP.BSI source code for further details about the other parameters and options, or to use the standard routine as the basis for your own customized version.