Page 1 of 3

Sending an Email from JCL with attachment

Posted: Tue Oct 07, 2008 4:22 pm
by muraligaru1
Hi,

In my project, one of the requirement is to send the mail to a group of people. attach a sequential file to that mail.

I have the JCL to send a simple mail.... i dont know, how to send an attachment with it. Please provide the jcl for this.


Thanks for help.

Posted: Wed Oct 08, 2008 10:34 am
by Kalicharan
This can be done using the below SAS program.

//MAILJCLX JOB (DEVLD,TEST),'MAILJCLX TEST',CLASS=X,MSGCLASS=X,NOTIFY=&SYSUID
//STEP0 EXEC SAS
//REPORT1 DD DSN=DVAN.MFDATASET.TEST,DISP=SHR
//SYSIN DD *
%LET MAILFILE = %SYSFUNC(PATHNAME(REPORT1));

DATA _NULL_;

CALL SYMPUT(?FDATE?, LEFT(PUT(?&SYSDATE?D-1,WORDDATE.)));

FILENAME LNOTE EMAIL TO=(?mail-id1? ?mail-id2?)
CC=(?ccmail-id1?)
BCC=(?bccmail-id1?)
SUBJECT =?TEST MAIL - &SYSDATE?
ATTACH =(?&MAILFILE? EXTENSION='TXT' TYPE='TEXT/PLAIN' NAME=?MFREPORT?);
DATA _NULL_;
FILE LNOTE ;
PUT
?This will be the content of the mail?;
PUT ' ';
RUN;

Here REPORT1 DSN will be send as attachment with the name MFREPORT.TXT in plain text format
to the mail-ids specified in ?FILENAME LNOTE EMAIL? with the subject TEST MAIL ? 03OCT08"

sending mail from JCL IEBGENER

Posted: Thu Oct 09, 2008 4:55 pm
by muraligaru1
Thanks Kalicharan.

Currently i am using IEBGENER to send a mail.

Is it possible to send an attachment using IEBGENER?
Please provide the JCL for the same.

sending an email from jcl with IEBGENER with attachment.

Posted: Sat Oct 11, 2008 2:16 pm
by Natarajan
Try following code.

Code: Select all

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

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

Posted: Sat Jan 24, 2009 2:46 am
by tavisha.sareen
I want to send multiple attachments in a single email through IEBGENER.Please suggest what needs to be done.

Posted: Sun Feb 08, 2009 8:40 pm
by snatcher
tavisha.sareen wrote:I want to send multiple attachments in a single email through IEBGENER.Please suggest what needs to be done.

Code: Select all

//PLNMMX05 EXEC PGM=IEBGENER                                  
//SYSPRINT DD SYSOUT=*                                        
//SYSIN    DD DUMMY                                            
//SYSOUT   DD SYSOUT=*                                        
//SYSUDUMP DD SYSOUT=D                                        
//SYSUT2   DD SYSOUT=&#40;B,SMTP&#41;                                  
//SYSUT1   DD DSN=JSULNC.MAIL.HELLO,DISP=SHR                
//              DD DSN=JSULNC.MAIL.ATTACH1,DISP=SHR              
//            DD DSN=JSULNC.REPORT.TEXT1,DISP=SHR  
//         DD DSN=JSULNC.MAIL.ATTACH2,DISP=SHR 
//            DD DSN=JSULNC.REPORT.TEXT2,DISP=SHR  


Contents of JSULNC.MAIL.ATTACH1 is:

Code: Select all

--MIME                                  
CONTENT-TYPE&#58; TEXT/PLAIN;NAME=RECY.TXT  
CONTENT-TRANSFER-ENCODING&#58; 7BIT          
CONTENT-DISPOSITION&#58; ATTACHMENT;        
FILENAME=JSULNC.BHAVANI.HELLO;          
                                        


Contents of JSULNC.MAIL.ATTACH2 is:

Code: Select all

 
MIME-VERSION&#58; 1.0                                
CONTENT-TYPE&#58; MULTIPART/MIXED;BOUNDARY="MIME"    
                                                
--MIME                                          
CONTENT-TYPE&#58; TEXT/PLAIN; CHARSET=US-ASCII      
CONTENT-TRANSFER-ENCODING&#58; 7BIT                  
                                                
HI ,          
                                    
    PLEASE FIND THE ATTACHED REPORTS. 

REGARDS 
SUPPORT TEAM 
                                                
--MIME                                          
CONTENT-TYPE&#58; TEXT/PLAIN;NAME=DIFF.TXT          
CONTENT-TRANSFER-ENCODING&#58; 7BIT                  
CONTENT-DISPOSITION&#58; ATTACHMENT;                
FILENAME=JSULNC.REPORT.TEXT2;            



Note:DCB of JSULNC.MAIL.ATTACH1, JSULNC.MAIL.ATTACH2, JSULNC.REPORT.TEXT2 and JSULNC.REPORT.TEXT1 should be the same. New line breaks is a must.

Posted: Sat Feb 21, 2009 3:39 am
by tavisha.sareen
Where do we need to put the email addresses to which the email needs to be sent and also let me know the content of file JSULNC.MAIL.HELLO.
Thanks

Posted: Sat Feb 21, 2009 1:16 pm
by snatcher
Hi There,

I missed the contents of the JSULNC.SMTP.HELO, it is as follows:

Code: Select all

HELO FELTG
MAIL FROM&#58; <XXXXXXXXXXXXXX@YYYYYYY.CO.UK>  
RCPT TO&#58; <yyyyyyyyyyyyyyyy@YYYYYYY.CO.UK>  
RCPT TO&#58; <ZZZZZZZZZZZZZZ@YYYYYYY.CO.UK>  
DATA                                               
FROM&#58; <XXXXXXXXXXXXXX@YYYYYYY.CO.UK>  
TO&#58; <yyyyyyyyyyyyyyyy@YYYYYYY.CO.UK>  
CC&#58; <ZZZZZZZZZZZZZZ@YYYYYYY.CO.UK>  
SUBJECT&#58; Report files attached 

Where FELTG is for handshaking, You should ask your mainframe admin for the handshake which you should use for successfull delivery of mail from your mainframe server.

Posted: Mon Feb 23, 2009 9:14 am
by tavisha.sareen
I am trying to do the same way u suggested but then m still getting a single attachment in the mail.Also I have csv files to attch in the email.
Please suggest..

Thanks

Email with attachmet

Posted: Mon Apr 13, 2009 1:11 pm
by subasu
Natarajan,

You JCL worked for an attachment. However, when I try to put in a body in the email like some written message, the attachment stops working. I am trying to put in the text/message between the SUBJECT and MINE-Version: 1.0. Please let me know if I am doing something wrong or suggest the correct format.

Thanks.
Subhadeep Basu.

Posted: Mon Apr 13, 2009 8:37 pm
by Natarajan
Hi Subhadeep,

Change the content 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: MULTIPART/MIXED;"SIMPLE BOUNDARY"
Hi,

How r you

Regards,
Natajan
--SIMPLE BOUNDARY
Content-Type: text/plain; name="XYZZ.txt"
Content-Disposition: attachment; filename="XYZZ.txt"


Let me know, if you still facing the issue.

Posted: Tue Apr 14, 2009 9:19 am
by subasu
Natarajan,

I am still facing the same issue, the mail is delivered, but there is no attachment, instead i get the following in the mail.
***********************************************************
Hi Nitin,
This is the test for body of the email
Thanks,
Subhadeep Basu
--SIMPLE BOUNDARY
Content-Type: text/plain; name="confirm.txt"
Content-Disposition: attachment; filename="confirm.txt"
PEON.CP000000.PCCS.FFB.CCS0P0000000000010000000000
************************************************************
The data"PEON.CP000000.PCCS.FFB.CCS0P0000000000010000000000" should come as an attachment.
-- Please let me know if you have a remedy for the same.

Posted: Tue Apr 14, 2009 3:10 pm
by Natarajan
Look like boundary is not working.. let me check and get back to you.

SMTP send attachment

Posted: Tue Apr 14, 2009 3:49 pm
by Natarajan
Hi,

please check below code.

Code: Select all

helo JOBTRAC 
MAIL FROM&#58;<Natarajan@gmail.com> 
rcpt to&#58;<Natarajan@gmail.com> 
data 
FROM&#58; xxxxx 
TO&#58; Natarajan@gmail.com 
SUBJECT&#58; test mail 
Mime-Version&#58; 1.0 
Content-Type&#58; MULTIPART/MIXED;boundary="mainframegurukul"

--mainframegurukul
Content-type&#58; text/plain

This is the body of the message.
--mainframegurukul
Content-Type&#58; text/plain; name="XYZZ.txt" 
Content-Disposition&#58; attachment; filename="XYZZ.txt" 


Make sure you have another PS file in SYSUT1, which contain following
--mainframegurukul--

OR

add this string at the end of the attachment data.

Posted: Tue Apr 14, 2009 3:54 pm
by subasu
Natarajan,

The following one worked.
===============================================
HELO SYSA
MAIL FROM:<XXXX@XXXX.COM>
RCPT TO:<XXXXX@XXXXX.COM>
DATA
FROM: <XXXXXXX@XXXX.COM>
TO: <XXXXXXX@XXXX.COM>
SUBJECT: Test Mail for attachment and body
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED;
boundary="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY

Hi Nitin,
This is the test for body of the email
Thanks,
Subhadeep Basu

--SIMPLE BOUNDARY
Content-Type: text/plain; name="confirm.txt"
Content-Disposition: attachment; filename="confirm.txt"
===============================================

Thanks for your help to get me started!!!