Sending an Email from JCL with attachment
Moderators: Frank Yaeger, DikDude, Moderator Group
- muraligaru1
- Moderator
- Posts: 43
- Joined: Sat Nov 11, 2006 7:03 pm
Sending an Email from JCL with attachment
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.
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.
- Kalicharan
- Moderator
- Posts: 31
- Joined: Wed Feb 08, 2006 1:51 pm
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"
//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"
- muraligaru1
- Moderator
- Posts: 43
- Joined: Sat Nov 11, 2006 7:03 pm
sending mail from JCL IEBGENER
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.
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.
Try following code.
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
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
-
- Member
- Posts: 6
- Joined: Sat Jan 24, 2009 2:43 am
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=(B,SMTP)
//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: TEXT/PLAIN;NAME=RECY.TXT
CONTENT-TRANSFER-ENCODING: 7BIT
CONTENT-DISPOSITION: ATTACHMENT;
FILENAME=JSULNC.BHAVANI.HELLO;
Contents of JSULNC.MAIL.ATTACH2 is:
Code: Select all
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED;BOUNDARY="MIME"
--MIME
CONTENT-TYPE: TEXT/PLAIN; CHARSET=US-ASCII
CONTENT-TRANSFER-ENCODING: 7BIT
HI ,
PLEASE FIND THE ATTACHED REPORTS.
REGARDS
SUPPORT TEAM
--MIME
CONTENT-TYPE: TEXT/PLAIN;NAME=DIFF.TXT
CONTENT-TRANSFER-ENCODING: 7BIT
CONTENT-DISPOSITION: 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.
Cheers!
Snatcher
Snatcher
-
- Member
- Posts: 6
- Joined: Sat Jan 24, 2009 2:43 am
Hi There,
I missed the contents of the JSULNC.SMTP.HELO, it is as follows:
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.
I missed the contents of the JSULNC.SMTP.HELO, it is as follows:
Code: Select all
HELO FELTG
MAIL FROM: <XXXXXXXXXXXXXX@YYYYYYY.CO.UK>
RCPT TO: <yyyyyyyyyyyyyyyy@YYYYYYY.CO.UK>
RCPT TO: <ZZZZZZZZZZZZZZ@YYYYYYY.CO.UK>
DATA
FROM: <XXXXXXXXXXXXXX@YYYYYYY.CO.UK>
TO: <yyyyyyyyyyyyyyyy@YYYYYYY.CO.UK>
CC: <ZZZZZZZZZZZZZZ@YYYYYYY.CO.UK>
SUBJECT: 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.
Cheers!
Snatcher
Snatcher
-
- Member
- Posts: 6
- Joined: Sat Jan 24, 2009 2:43 am
Email with attachmet
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.
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.
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.
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.
Natarajan
Chennai
Chennai
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.
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.
SMTP send attachment
Hi,
please check below code.
Make sure you have another PS file in SYSUT1, which contain following
--mainframegurukul--
OR
add this string at the end of the attachment data.
please check below code.
Code: Select all
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;boundary="mainframegurukul"
--mainframegurukul
Content-type: text/plain
This is the body of the message.
--mainframegurukul
Content-Type: text/plain; name="XYZZ.txt"
Content-Disposition: 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.
Natarajan
Chennai
Chennai
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!!!
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!!!
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page