IBM i Emails with IFS attachments from RPG and CL using SNDSMTPEMM

Life as a IBM i Software Developer is fun, but life as an AS400 software maintenance programmer can be a bit grim.

I seem to spend the bulk of my time maintaining older applications – archaic code monstrosities that started life in the AS400 generation. “The AS400 generation?” You remember these days in the early 90’s when email was a new an exciting thing, Yahoo was the search engine of choice and the phrase ‘social networking’ hadn’t been dreamed up. So, when I find that a new exciting snippet of IBM i Software has slipped passed my radar it gets me all twitchy.

Guess what I found out today?

SNDSMTPEMM is a native IBM i command that will send emails with IFS attachments!

By native I mean, it comes quietly packaged with the operating system. I can now send emails from within RPGLE programs or from the command line by simply entering the command. I can attach any kind of files from the IFS (PDF, TXT, HTML, XML, yadda yadda) and I can even format the body of the emails using HTML to make it look all pretty.

RPG Code SnippetSNDSMTPEMM RCP((myemail@something.com))
SUBJECT('This is a test email from IBM i V7R1')
NOTE('<H1>This is the body of the email</H1>
<p>I can enter things using HTML and format things in a most pretty way</p>
<p><i>cool</i>')
ATTACH(('/home/nlitten/QSYSPRT_[08-22-2013_12.41.38].PDF' *OCTET *BIN))
CONTENT(*HTML)

All those times I’ve spent playing with SNDDST command which only supports the old DLS format.

All those other times I have spent twiddling with MMAIL or RPGMAIL addon applications to do nice looking emails with attachments. Now I can do it all native on the machine, with no *API calls.

Very cool stuff.

Because the SNDSMTPEMM command is delivered midrelease, it’s provided only as an uppercase English version, as opposed to the various language versions usually provided to reflect and honor the system’s primary language configuration. Because of this circumstance, no help text panel group is included either. All this will, of course, be corrected in the IBM i release following 7.1.

For the time being however, the SNDSMTPEMM lacks the online help text that would let users instantly access information about the command and its parameters. To somewhat make up for this shortcoming, IBM recently released a technical document, “SNDSMTPEMM Command Instructions,” providing the SNDSMTPEMM command documentation, similar in format to what is typically available online for native IBM commands. To access the technical document, however, an IBM user ID and password is required.

So, we can now send IBM i objects, IFS and *SPLFS using a built in native EMAIL command.

First I want to say WELL DONE IBM and second I will add in slightly quieter type AND ABOUT BLOODY TIME! 🙂

SNDSMTPEMM Documentation can be found here

NOTE: MMAIL is awesome. I cannot fault it. This is my go-to email package of choice before I found this hidden IBM gem. A fantastic email package, offered free from www.easy400.net and if you are on an older version of IBM i or just want to explore alternatives – then check it out.