(Originally posted 2013-01-24.)
Another kernel popped the other day: SMTP / MIME.
But what on earth is MiGueL Mainframe š troubling himself with SMTP / MIME for? Let’s come at this from a different angle…
You probably know by now that when you send me your data it gets put through some batch reporting: Ultimately I don’t create the graphs by hand, but I do do the analysis and put the presentation together myself. That’s the “high value” creative part.
Workflow
You probably also know that the JCL to build performance databases and do the reporting is generated using ISPF File Tailoring and some panels.
But what about the actual workflow? In broad terms it’s pretty much all the same – for each engagement: I’d like my “to do” list for a project to be automatically generated. And I might well want some other notes to be automatically generated – perhaps a slide template or a “lessons learned” boilerplate note or something.
For most of my life I keep notes in a very fine service: Evernote. I also keep my “to do” list in Remember The Milk. I’m sure other fine services exist but these are the ones I use – and the ones I know the following technique work for.
I’d like to automate my workflow, as I said, and some of my engagement-related documentation.1.
Both Evernote and Remember The Milk supply an email address specific to an account: If you knew my Evernote email address, for instance, you could email in a note and Evernote would store it for us.2 So I can teach any email client how to add notes to Evernote and “to do” items to Remember The Milk. The latter accepts a list of items, along with due dates, priorities etc.
(To find your Evernote email address see here. Likewise for Remember The Milk.)
Between them I’m sure I can automate quite a lot of workflow, while continuing to make careful choices to keep client information secure.
Email and z/OS / TSO Batch
So why not have my JCL generator include some steps to generate this material?
Though that was a rhetorical question it does have an answer. š You have to make it so – with a SMOP. š
But actually it’s not difficult.
In “Standing On The Shoulders Of Giants“3 Mode, I notice we already have a jobstep – very early in our process flow – that uses XMIT to send a small tracking file, containing a File-Tailored set of information about the study. It’s a flat file but it points the way. It doesn’t use SMTP and it doesn’t include HTML.
I found out the appropriate SMTP address that my z/OS system has access to. With it I can send emails to anywhere – inside IBM and beyond (as Evernote and RTM both are).
Putting It Together
I’ve already created a batch job that can send HTML-formatted emails. It looks like this:
//XMITSMTP EXEC PGM=IKJEFT01,DYNAMNBR=50,REGION=0M //* //SYSOUT DD SYSOUT=K,HOLD=YES //SYSPRINT DD SYSOUT=K,HOLD=YES //SYSTSPRT DD SYSOUT=K,HOLD=YES //SYSTSIN DD DDNAME=SYSIN //SYSUDUMP DD SYSOUT=K,HOLD=YES //SYSIN DD * XMIT <smtp server address> NONOTIFY + MSGDSNAME('<userid>.JCL.LIB(SMTPDATA)') /* //*
In the above I chose to use MSGDSNAME rather than DSNAME to point to the data. This stands a better chance of having the EBCDIC translation work right. It points to the actual MIME message:
Helo MVSHOS mail from:<martin_packer@uk.ibm.com> rcpt to:<to-address> data From: martin_packer@uk.ibm.com To: to-address Subject: This is a test MIME-Version: 1.0 Content-type: multipart/mixed; boundary="simple boundary" You have received mail whose body is in the HTML Format. --simple boundary Content-type: text/html <font face="Arial" size="+2" color="blue"> This is Arial font in blue. </font> <br/> <ul> <li>One</li> <li>Two</li> </ul> <font face="Arial" size="+3" color="red"> This is the Arial font bigger and in red. </font> --simple boundary
This is in what is called “multipart MIME format” – and you can tell this from the “Content-type: multipart/mixed;” line. (Each part is separated by the line “simple boundary”.) The HTML is obvious and the fact it is to be treated as HTML is indicated by the “Content-type: text/html” line.
One of the things this illustrates is that sending HTML by email isn’t complicated at all.
Note:The actual “to address” in the “rcpt” line needed a relay address in my case – preceded by an “@” and separated from the eventual address by a “:”. You might need one too.
When I sent this HTML to Evernote it worked fine and I have a nicely formatted note, complete with the title preserved. If you want to understand how Evernote handles emails look here. For Remember The Milk look here.
The note in Evernote looked very much like this:
This is Arial font in blue.
- One
- Two
As I said earlier, sending an HTML-formatted email is not significantly more difficult than sending a plain text one. I hope this blog post demonstrates that: Examine the code you’re using today to send emails from z/OS and I think you’ll agree. And I think you’ll find cases where it would be a better solution.
On a final note, IBM (and others) have email solutions. And indeed workflow solutions. Those have their own applicability – for the more complex or larger-scale applications.
But if you want “lightweight”, “simple”, “informal” workflow my approach might make sense to you. As it is I’m going to build this, small pieces at a time – like I do most of my development work.
Notes:
1 I’m very clear about not compromising customer data or situations. Customer confidentiality is key – and along with other cloud services – I can’t store sensitive or identifiable data in Evernote or Remember The Milk.4. Similarly, I’m incredibly circumspect in reviewing customer-related stuff in public places.
2 Obviously this is open to abuse – as anyone with the email address can fill your account up with SPAM. But you can change the email address at any time – and I don’t give it out often.
3 When I first heard this cliché I thought it was Albert Einstein. And later on I thought (slightly more accurately) it was Isaac Newton. Obviously giving Maths/Physics giants more credit than they’re due. I wonder why. š
4 As one of the authors of this piece of the IBM Social Computing Guidelines I’d urge you to read this short document to understand IBM’s stance.
FYI – you don’t need the MIME multipart bit unless you are trying to construct an email with … *drumroll* … multiple parts. To create a plain HTML email you can just include the bit from Content-type: text/html down and remove the boundary lines. I was driven nuts with the above approach because it kept creating a superfluous ATT00001.txt attachment once it hit Exchange. By removing the multipart directives I solved my problem.
LikeLike
Thank you Jonathan. I might experiment with this some more. By the way I’ve moved from Evernote and Remember The Milk to Drafts and OmniFocus, respectively.
And I might actually do multi-part. I’ll try to think of some creative uses.
LikeLike