Having trouble determining a user's email address for SNDDST? Read on.
As time passes, there appears (to me at least) to
be a decreasing popularity in the standard printed report, particularly when
green-bar paper is used. Accurate or not, some users associate paper of this
nature with punch cards and anti-productivity. Rewriting entire applications is
not necessarily among the available options, but delivering a document by email
is quick and easy, and it satisfies the user community.
The scenario
starts the way it always has. The user selects an option from a 5250-based menu.
A small amount of extra programming converts the spool file into text, a Web
page, a PDF, or another type of output. The output is then emailed to the user
who pushed the button.
The question is how we determine the user's email
address. For many years, I was in a shop where the user ID was the same as the
first part of the email address. The last part was always the same. Determining
the email address was as easy as concatenating the user ID to the domain. When I
started working for another enterprise, I quickly discovered that not all shops
work this way.
The good news is that in order for the user to use the
Send Distribution (SNDDST) command to send an email, the user must have a
directory entry and an SMTP name. The bad news is that there is no command to
retrieve the SMTP name. I started researching Display Directory Entry (DSPDIRE)
to an outfile, but no luck. Then, I came across a screen that displayed the SMTP
name (Figure 1):
Figure 1: This screen displays the SMTP name. (Click image to
enlarge.)
Despite i5/OS presenting this screen, there is no
DSPNMESMTP command or anything like it. This screen is available only by
pressing a function key from a Work with Directory Entry (WRKDIRE)
screen.
Yet the user's email address was displayed. It was only a
question of doing a little detective work to obtain the source. By pressing the
System Request key and selecting option 14 to see what files are being used, the
IBM-supplied file QSYS/QATMSMTPA is discovered. It's here that the email address
is stored.
A problem remained: The email address was not being stored as
an email address. The user portion and the domain portion were stored in
separate fields, and the at sign (@) was nowhere to be found. The two small
programs that are included with this article provided the finishing touches.
RTVEMLRPG retrieves the appropriate data and formats that data into a proper
email address. RTVEMLCLP determines the user ID and address in order to return
the email address to a calling program.
There is a great deal of flexibility
here:
- I used 36 characters for the email address. You may choose to use more
or less.
- I chose not to create a command. There is no particular reason why
this cannot be done.
- RTVEMLRPG may be turned into a procedure.
- You can
retrieve the email address for any user, not necessarily the user calling the
program.
The results proved to be most satisfactory for those who were
relying on the information contained therein. Now, everyone at this shop wants
reports delivered by email, and I have more work to
do.
David Abramowitz is an independent
consultant. His email address can be found a bit easier:
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
.
|