TechTip: Using Your iSeries as a Mail Client

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
Recently, someone asked me about using the iSeries to re-process and report on "undeliverable" email. He was sending out a lot of email using the QtmmSendMail API and the SMTP server in OS/400 (i5/OS if you are keeping up). The problem was that email messages that were returned as "undeliverable" were being ignored because the email messages were being retrieved by one of the PC-based mail clients (Outlook, Eudora, Thunderbird, etc.). The obvious answer is to retrieve the messages to the iSeries and handle them from there.

The simplest way to accomplish this is to use the QRYDST and RCVDST commands. Until my friend set me on a course to determine how to process email on the AS/400 or iSeries, I was unfamiliar with the QRYDST command. Also, I had only used the RCVDST command for receiving files that had been sent using SNDDST (generally, *SAVF files or spooled files). Imagine my surprise when I found that these two commands easily provide the foundation for a simple email client.

The first order of business in retrieving email is to get the list of the available email messages. The QRYDST command allows you to retrieve all the incoming email either for a specific user ID or for any users that the current user has been given authority to. For our purposes, we will stick to retrieving email for a single user.

The IBM iSeries Information Center offers some documentation about using SNADS to receive email, but it's not clear on the format of the information that the QRYDST command retrieves. You have to dig into the QRYDST command documentation to discover that library QSYS contains two files, QAOSILIN and QAOSILOT. These files are the templates for the output from the QRYDST and RCVDST commands. Once you have this information, the IBM documentation for receiving emails using QSNADS makes much more sense. The following command retrieves the list of email messages for user ID JOLEN to a file called MAILLIST in library JEFFO.

QRYDST USRID(JOLEN DEV40001) OUTFILE(JEFFO/MAILLIST)


Once the list of email messages is retrieved into a file using the QRYDST command, you will use the distribution identifier (field LINDID from the QAOSILIN template) and the RCVDST command to retrieve the specific email messages. IBM has provided a template file in QSYS called QAOSIRCV that shows the format of the RCVDST output file. The following command will retrieve a specific email message identified by the distribution ID into the file MAILMSGTMP in library JEFFO.

RCVDST DSTID('QTCP    QTCP    0068') USRID(JOLEN DEV40001)       OUTFILE(JEFFO/MAILMSGTMP)                                                                        


The IBM RCVDST documentation in the Information Center gives good details on the contents of the email messages. From there, it's up to you, the developer. Really, you could write a simple application to re-process and report on any undeliverable email either from the email list from QRYDST or from the actual message retrieved by RCVDST. Have fun!

Jeff Olen is a Software Engineer on the iSeries R&D team at Open Text Corporation in Irvine, California. He has over 15 years of development experience on midrange systems and can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it..

Jeff Olen

Jeff Olen is a super-spy now but keeps his cover identity intact by working for video game studios on the East Coast. So when he’s not out killing members of ISIS or rescuing refugees, you can find him playing Wolfenstein II or testing the new Fallout 76 releases at his beach house in Costa Rica. In any case, he can’t be reached. You can email his cat at This email address is being protected from spambots. You need JavaScript enabled to view it.. She will pass on your message…if she feels like it.


MC Press books written by Jeff Olen available now on the MC Press Bookstore.

The IBM i Programmer’s Guide to PHP The IBM i Programmer’s Guide to PHP
Get the scoop on how PHP can—and should—be deployed on IBM systems.
List Price $79.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: