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

  • Home
  • /
  • Blog
  • /
  • IBM i Emails with IFS attachments from RPG and CL using SNDSMTPEMM

November 25, 2012

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.

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>
ATTACH(('/home/nlitten/QSYSPRT_[08-22-2013_12.41.38].PDF' *OCTET *BIN))

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 and if you are on an older version of IBM i or just want to explore alternatives – then check it out.


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

  • Nick tnk U for nice example ! My appetite after this article was growing to include into body message the picture stored on any IFS folder, so I have a question to Nick and other skilled developers: How I need to specify the IFS path to particular image stored on IFS folder in case when I want to add HTML tag to display it inside of the message body ( inside NOTE parameter of comprised of HTML tags)

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Start your
    7-day free trial

    Take This Course with ALL ACCESS

    Unlock your Learning Potential with instant access to every course and all new courses as they are released.
     [ For Serious Software Developers only ]

    IBM i Training For Technology Experts


    Successfully Work Remote 

     $ 129.00  $59.00

    By adding new skills in information technology, employers will be confident that you have the necessary skills and tools needed to successfully work remotely


    Snug CBD

     20% Discount

    I have partnered with SNUG CBD givING you Organic CBD
    20% discount code "NL20"