Sending an Email from JCL with attachment

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Tue Nov 03, 2009 2:34 am


sumit_saxena
Member
Posts: 1
Joined: Sat Oct 02, 2010 1:56 am

how to attach a pdf in JCL

Post by sumit_saxena » Thu Oct 07, 2010 2:25 am

Hi,
I have used TXT2PDF function to create PDF encoded member in a PDS.

Now I am trying to send that PDS member as an attachment of type PDF file inside a JCL which uses IEBGENER.

The email is being sent correctly but the IEBGENER does not includes all the complete encoded file and hence which the email comes with attahment, the adobe is unable to decode or read the file and gives an error.
Can anybody please help or suggest an alternative program which used instead of IEBGENER.

Below is my JCL.
--------------------------------------------------------------------------------
//APSSLD1A JOB (PSSBTT,PSS),'ID',
// NOTIFY=APSSSS2,MSGLEVEL=(1,1),REGION=0M,MSGCLASS=C
/*NOTIFY APSSLD1 *** ADDED BY SUBMIT EXIT ***
//NORMRC EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DISP=SHR,DSN=XPSS01.SUMIT.TEMP(DEST1)
// DD DISP=SHR,DSN=XPSS01.SUMIT.TEMP(DEST2)
// DD DISP=SHR,DSN=XPSS01.SUMIT.TEMP(DEST3)
//SYSUT2 DD SYSOUT=(B,SMTP)
//SYSIN DD DUMMY
//*
---------------------------------------------------------------------------------

Member DEST 1 - this containes the details on where the email should be delivered

HELO JOBTRAC
MAIL FROM:<abc@abc.com>
RCPT TO:<abc@abc.com>
DATA
FROM: SUMIT
TO:SUMIT
SUBJECT: AUTOMATED EMAIL
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE"

--SIMPLE
CONTENT-TYPE: TEXT/PLAIN; CHARSET="ISO-8859-1"
CONTENT-TRANSFER-ENCODING: BINARY

THIS IS TEST EMAIL FROM SUMIT

--SIMPLE
CONTENT-TYPE: APPLICATION/PDF;NAME="XYZZ.PDF"
CONTENT-TRANSFER-ENCODING: BINARY
CONTENT-DESCRIPTION: TRAVEL COSTING ONLINE REPORT
CONTENT-DISPOSITION: ATTACHMENT; "XYZZ.PDF"
--------------------------------------------------------------------------------

Dest 2 contains the encoded format for PDF
&àã
?¦

äÊÁ/ÈÑ?>à/ÈÁ à
&Ê?ÀÍÄÁÊ èìè &àã Â` (å( ?à í>ÑÎ åÁ?ÊÅÑ/
èÑÈ%Á í+.+|ï+

Á>À?¦
?¦

è`øÁ ã?>È
ëÍÂÈ`øÁ è`øÁ
á>Ä?ÀÑ>Å ëÈ/>À/ÊÀá>Ä?ÀÑ>Å
â/ËÁã?>È ä?ÍÊÑÁÊ â?%À

Á>À?¦
?¦
---------------------------------------------------------------------------
Dest 3 - contains the end qualifier

--simple--

--simle--
---------------------------------------------------------------------------


Now the problem is which I submit this JCL it does not reads the encoded file DEST2 correctly, below is what it interprets.

&
? ¦

/ ?> /
& ? & ` ( ( ? > ? /
% +.+| +

> ? ¦
? ¦

-----------------------------------------------------------------------------

As you see some of the encoded characters it is unable incorporate in the JCL

Any suggestions/comments will really appreciated.
Thanks.
Sumit

sandeep.R
Member
Posts: 1
Joined: Wed Jul 06, 2011 2:47 pm

Re: sending an email from jcl with IEBGENER with attachment.

Post by sandeep.R » Wed Jul 06, 2011 2:56 pm

Natarajan wrote:Try following code.

Code: Select all

//SENDMAIL JOB &#40;XXX,YYY&#41;,                                            
//             'MAIL FILE ',                                            
//             MSGCLASS=T,                                              
//             CLASS=S                                                                            
//*                                                                     
//STEP01   EXEC PGM=IEBGENER                                            
//SYSIN    DD  DUMMY                                                    
//SYSPRINT DD  SYSOUT=*                                                 
//SYSUT2   DD  SYSOUT=&#40;M,SMTP&#41;                                          
//SYSUT1   DD  DISP=SHR,                                                
//                  DSN=DEV.XXXX.TEST.FILE
//              DD DISP=SHR,     
//                  DSN=DEV.XXXX.TEST.FILE2&#40;0&#41; 
//*      

Contents of the file DEV.XXXX.TEST.FILE :
helo JOBTRAC
MAIL FROM:<Natarajan@gmail.com>
rcpt to:<Natarajan@gmail.com>
data
FROM: xxxxx
TO: Natarajan@gmail.com
SUBJECT: test mail
Mime-Version: 1.0
Content-Type: text/plain; name="XYZZ.txt"
Content-Disposition: attachment; filename="XYZZ.txt"

DEV.XXXX.TEST.FILE2(0) is the file which should be send as attachment
Both files DCB?s should match.


Let me know, if you face any problems with this JCL







if we use the above method we are getting the following errors..............can u please help on this

Unable to deliver mail to some/all recipients.
050 DATA 00000400
501 Syntax Error. No Args after 'DATA' command
050 FROM: SANDEEP.SANDEEP.R@AEXP.COM 00000500
500 Unknown command, 'FROM'
050 TO: KALYAN.C.MUNUKOTI@AEXP.COM 00000600
500 Unknown command, 'TO'
050 SUBJECT: TEST MAIL 00000700
500 Unknown command, 'SUBJECT'
050 MIME-VERSION: 1.0 00000800
500 Unknown command, 'MIME'
050 CONTENT-TYPE: MULTIPART/MIXED; 00000900
500 Unknown command, 'CONTENT'
050 BOUNDARY="SIMPLE BOUNDARY" 00001000
500 Unknown command, 'BOUNDARY'

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Wed Jul 06, 2011 5:30 pm

050 DATA 00000400 <=== You have numbers in your data ...
050 FROM: SANDEEP.SANDEEP.R@AEXP.COM 00000500 <===

Aravindan
Member
Posts: 2
Joined: Mon Feb 29, 2016 2:30 pm

Post by Aravindan » Mon Feb 29, 2016 2:39 pm

//SENDMAIL JOB (XXX,YYY),
// CLASS=9,MSGCLASS=Y,
// MSGLEVEL=(1,1),REGION=0K
//*
//STEP01 EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD SYSOUT=(M,SMTP)
//SYSUT1 DD DISP=SHR,
// DSN= ARARJ1.JCLLIB.SENDMAIL.TEST(FILE1)
// DD DISP=SHR,
// DSN= ARARJ1.JCLLIB.SENDMAIL.TEST(INPUT)
//*



Hi,

Am new to mainframe i used above query to send mail... but am getting jcl error message like

STMT NO. MESSAGE
6 IEFC621I EXPECTED CONTINUATION NOT RECEIVED
7 IEFC605I UNIDENTIFIED OPERATION FIELD
8 IEFC621I EXPECTED CONTINUATION NOT RECEIVED
9 IEFC605I UNIDENTIFIED OPERATION FIELD


Plz clarify..


Regards,
Aravindan

Aravindan
Member
Posts: 2
Joined: Mon Feb 29, 2016 2:30 pm

Post by Aravindan » Mon Feb 29, 2016 3:15 pm

[quote="Aravindan"]//SENDMAIL JOB (XXX,YYY),
// CLASS=9,MSGCLASS=Y,
// MSGLEVEL=(1,1),REGION=0K
//*
//STEP01 EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD SYSOUT=(M,SMTP)
//SYSUT1 DD DISP=SHR,
// DSN= ARARJ1.JCLLIB.SENDMAIL.TEST(FILE1)
// DD DISP=SHR,
// DSN= ARARJ1.JCLLIB.SENDMAIL.TEST(INPUT)
//*



Hi,

Am new to mainframe i used above query to send mail... but am getting jcl error message like

STMT NO. MESSAGE
6 IEFC621I EXPECTED CONTINUATION NOT RECEIVED
7 IEFC605I UNIDENTIFIED OPERATION FIELD
8 IEFC621I EXPECTED CONTINUATION NOT RECEIVED
9 IEFC605I UNIDENTIFIED OPERATION FIELD


Plz clarify..


Regards,
Aravindan[/quote]


Hi i have solved this problem and thats because i have not specified job name properly..


But after the job run am not receiving the mail..

fabianarnold
Member
Posts: 1
Joined: Wed Feb 10, 2016 8:12 pm

Post by fabianarnold » Fri Mar 04, 2016 3:10 pm

from SMTP Email - body with an attachment question
http://ibm mainframes .com/about 55814.html


//SENDMAIL EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *
HELO MAINFRAME
MAIL FROM: <TESTUSER1@TEST.COM>
RCPT TO: <TESTUSER2@TEST.COM>
DATA
FROM: <TESTUSER1@TEST.COM>
TO: <TESTUSER2@TEST.COM>
SUBJECT: This is a test mail
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY

Hello
Please check the attached file.
Bye.
--SIMPLE BOUNDARY
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=Attachment.txt
// DD DISP=SHR,DSN=AttachedMainframeDataset
// DD *
.
QUIT
/*
//SYSUT2 DD SYSOUT=(B,SMTPStartedtaskName)
//SYSOUT DD SYSOUT=*

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others