0

How to write JCL to send an email but the content(Data) should be picked from another PDS/member. If anyone can let me know the JCL for what I need will be helpful.**

Saurav
  • 11
  • 1
  • 1

3 Answers3

3

Here is an old example but it sounds like what you are looking for. It uses IEBGENER to send an e-mail. (I didn't write the content so complain to IBM if you don't like it.)

This is from Knowledge Center

//BATSMTP  JOB (userid,nn),MSGCLASS=B,PRTY=12,MSGLEVEL=(2,1)
//*
//* Store message in a PDS
//*
//PUTMSG   EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSUT1 DD *
HELO YOURMVS
MAIL FROM:<CAROL@YOURMVS>
RCPT TO:<msgs@rsch.our.edu>
RCPT TO:<alice@ai.our.edu>
DATA
Date: Thur, 26 Mar 92 21:48:57 EST
From: Carol <CAROL@YOURMVS>
To:   <msgs@rsch.your.edu>
Cc:   <alice@ai.your.edu>    Subject: update

 Mike: Cindy stubbed her toe.  Bobby went to 
       baseball camp.  Marsha made the cheerleading team. 
       Jan got glasses.  Peter has an identity crisis. 
       Greg made dates with 3 girls and couldn't 
       remember their names. 
 .
 QUIT
 /*
 //SYSUT2 DD DSN=MYPDS.OF.MESSAGES(MSGID1),DISP=SHR
 //*               
 //SYSPRINT DD SYSOUT=A
 //*               
 //* Send Message from placed in PDS in prior step               
 //*               
 //SENDMSG  EXEC PGM=IEBGENER
 //SYSIN    DD  DUMMY
 //SYSUT1   DD  DSN=MYPDS.OF.MESSAGES(MSGID1),DISP=SHR
 //*
 //SYSUT2   DD  SYSOUT=(B,smtp)
 //*                 |   v
 //*                 v  SMTP address space name for external writer
 //*                SYSOUT class
 //SYSPRINT DD  SYSOUT=A
Hogstrom
  • 3,581
  • 2
  • 9
  • 25
  • Thanks for your reply. But the content is already there in the JCL mentioned by you. I want the content to be picked up from other PDS. Talking about this. Mike: Cindy stubbed her toe. Bobby went to baseball camp. Marsha made the cheerleading team. Jan got glasses. Peter has an identity crisis. Greg made dates with 3 girls and couldn't remember their names. – Saurav Jun 17 '20 at 18:00
  • 1
    This is how you would send it. You would need to create the content in a PDS and then reference that in SYSUT1. So, is your real question how to create content in a PDS ? Your question is what JCL to send an e-mail ... now your changing the question to how to put data in a PDS member. Can you clarify what you are really looking for? – Hogstrom Jun 17 '20 at 18:29
  • My question is to send an email with relevant data. But the data should not be directly written in the same JCL code. It should be fetching it from different PDS. But if you can let me know how to reference it then it can make my work easy. – Saurav Jun 17 '20 at 18:45
  • Added a first step to copy the message to a PDS and then reference that PDS in the send step. Note you could create multiple messages in or outside this JOB. Good luck – Hogstrom Jun 18 '20 at 03:07
2

Concatenate your PDS member with your other stuff in SYSUT1 e.g.

//SYSUT1 DD *
your stuff here
//       DD DSM=your.pds(member),DISP=SHR

`You may need other stuff after your member - just concatenate more DD *. Remember that your PDS data must be LRECL=80

NicC
  • 293
  • 1
  • 6
0

Concatenation works fine if all source data has the same DCB. If not, use SORT to create a temporary VB file with LRECL = your longest LRECL + 4. E.g., if you need to merge 80-byte PDS data with 133-byte reports, use SORT to copy everything to a VB file with LRECL=137 and send that to the sysout.

If anyone is still reading, I'd like to find out how to set up a BCC: recipient. Apparently, only TO: and CC: are supported.

Sample JCL for building the VB file:

000007 //BUILD PROC                                                            
000008 //SORT    EXEC PGM=SORT                                                 
000009 //SORTOUT  DD  DISP=(MOD,PASS),DSN=&&EMAIL,UNIT=SYSDA,                  
000010 //       SPACE=(CYL,(1,1)),DCB=(RECFM=VB,LRECL=430,BLKSIZE=27998) 
000011 //*                                                                     
000012 //SYSIN    DD *                                                         
000013  OPTION COPY                                                            
000014  OUTFIL FNAMES=SORTOUT,FTOV                                             
000015 //SORTWK01 DD SPACE=(CYL,(5,5),RLSE),UNIT=SYSDA                         
000016 //SORTWK02 DD SPACE=(CYL,(5,5),RLSE),UNIT=SYSDA                         
000017 //SORTWK03 DD SPACE=(CYL,(5,5),RLSE),UNIT=SYSDA                         
000018 //SORTWK04 DD SPACE=(CYL,(5,5),RLSE),UNIT=SYSDA                         
000019 //SORTWK05 DD SPACE=(CYL,(5,5),RLSE),UNIT=SYSDA                         
000020 //SYSPRINT DD SYSOUT=*                                                  
000021 //SORTMSG  DD SYSOUT=*                                                  
000022 //SYSDBOUT DD SYSOUT=*                                                  
000023 //SYSUDUMP DD SYSOUT=*                                                  
000024 //SYSOUT   DD SYSOUT=*                                                  
000025 //*                                                                     
000026 // PEND                                                                 
000027 //*                               
000028 //HEADER EXEC BUILD -------------------------------------------- 
000029 //SORT.SORTOUT DD DISP=(,PASS)                                          
000030 //SORT.SORTIN DD *                                                      
000031 HELO MVSOSA.CAPITALONE.COM                                              
000032 MAIL FROM:<{from address}>                             
000033 RCPT TO:<{to address}>                               
000034 DATA                                                                    
000035 FROM: <{from address}>                                 
000036 TO:<{to address>                                    
000037 SUBJECT: {subject}        
000038 MIME-Version: 1.0                                                       
000039 Content-type: multipart/mixed; boundary="=_boundary"                    
000040                                                                         
000041 These comments don't show up in the email.                              
000042                                                                         
000043 Note: After each boundary, one or more records describes the 
000044       content that follows. After the last "Content-..." record 
000045       in each section, be sure to have a blank line.                            
000046                                                                         
000047                    
000049                                                                         
000050 See also https://www.ibm.com/support/pages/                             
000051          outbound-email-attachments-using-smtp-or-cssmtp-zos            
000052                                                                         
000053 --=_boundary                                                            
000054 Content-Type: text/plain;                                               
000055                                                                         
000056 Good day.                                                               
000057 Please find attached the reports you wanted. 
000058                                                                         
000059 Regards -- Me                           
000060                                                                         
000061 --=_boundary                                                            
000062 Content-Type: application;                                              
000063 Content-Disposition: attachment; filename={report name}.txt
000064 Content-Transfer-Encoding: 8bit;                                        
000065                                                                         
000066 /*                                                                      
000067 //STATRPT EXEC BUILD                                                    
000068 //SORT.SORTIN DD  DISP=SHR,DSN={file name with report}                         
000069 //*                                                                     
000070 //*                                                                     
000071 //*-------------------------------------------------------------*
000072 //EMAILSTP EXEC PGM=IEBGENER                                            
000073 //SYSPRINT DD  SYSOUT=*                                                 
000074 //SYSIN    DD  DUMMY                                                    
000075 //SYSUT2   DD  SYSOUT=(B,SMTP)                                          
000076 //SYSUT1   DD  DISP=(OLD,PASS),DSN=&&EMAIL                              
000077 //*                                                                     
000078 //*==============================================================
000079 //*