How to attach multiple files in one e-mail using SMTP?

JES2/3, JCL, utilities.
Post Reply
Sandeep Joshi
New Member
Posts: 6
Joined: Tue Apr 29, 2014 1:47 pm

How to attach multiple files in one e-mail using SMTP?

Post by Sandeep Joshi »

Hello,

I need to attach multiple files in one e-mail. I'm using the below JCL:

Code: Select all

//SENDNOTE EXEC PGM=IEBGENER 
//SYSPRINT DD SYSOUT=* 
//SYSUT2 DD SYSOUT=(B,SMTP) 
//SYSIN DD DUMMY 
//SYSUT1 DD *,LRECL=133 
//SYSUT1 DD *,LRECL=133 
HELO MVS 
MAIL FROM:sandeepjoshi@xyz.com 
RCPT TO:sandeepjoshi@xyz.com 
DATA 
FROM:sandeepjoshi@xyz.com 
TO:sandeepjoshi@xyz.com 
SUBJECT: TEST REPORT 
MIME-VERSION: 1.0 
CONTENT-TYPE: MULIPART/MIXED; CHARSET=US-ASCII 
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=REPORT1
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=REPORT2

// DD DISP=SHR,DSN=ABCD.REPORT1 
// DD DISP=SHR,DSN=ABCD.REPORT2
I'm not able to get it, please help!
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: How to attach multiple files in one e-mail using SMTP?

Post by Robert Sample »

My experience has been that multi-part MIME, which is what you want to use, works with SMTP on a z/OS system but is EXTREMELY sensitive to the format used (for example, you must use a BOUNDARY, you must put everyone for the first attachment together before starting the second attachment, and you must specify the data type correctly). What you have posted will not, under any circumstances, produce multiple attachments due to these deficiencies.

Commands I have successfully used in the past to send multiple attachments:

Code: Select all

HELO MAINFRAME.domain.com
MAIL FROM: <MAINFRAME@domain.COM>
RCPT TO: <ROBERT.SAMPLE@domain.COM>
DATA
FROM:     MAINFRAME@domain.COM
TO:       ROBERT.SAMPLE@domain.COM
DATE:     OCTOBER 27, 2014
SUBJECT:  TEST ATTACHMENT
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=EMAILATT.TXT

//         DD   DISP=SHR,DSN=TTSSRS0.JCL.CNTL(EMAILATT)
//         DD   *
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=EMAILTST.TXT

//         DD   DISP=SHR,DSN=TTSSRS0.JCL.CNTL(EMAILTST)
//         DD   *
--SIMPLE BOUNDARY--
//         DD   DISP=SHR,DSN=TTSSRS0.JCL.CNTL(EMAILAT)
//
As an example of the sensitivity, the blank lines after the CONTENT-DISPOSITION lines are NOT optional -- if you don't put a blank line, the email will not go out as you want.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “JCL - Job Control Language.”