Page 1 of 2

Email an attachment

PostPosted: Sat Jun 18, 2011 1:13 pm
by Srini Srini
Hello,

I am trying to email an attachment from mainframe using IEBGENER. My JCL is:
//MAILPROC EXEC PGM=IEBGENER
//SYSABEND DD SYSOUT=*
//SYSTOTAL DD SYSOUT=*
//SYSLIST DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD SYSOUT=(A,SMTP)
//SYSIN DD DUMMY
//*
//SYSUT1 DD DSN=USERID.INPUT.CARDS,DISP=SHR
// DD DSN=USERID.DCOL.DATASETS,DISP=SHR

Content of USERID.INPUT.CARDS is as below:

HELO MAILST1
MAIL FROM: <NAME@COMPANY.COM>
RCPT TO: <NAME@COMPANY.COM>
DATA
FROM: <NAME@COMPANY.COM>
TO: <NAME@COMPANY.COM>
SUBJECT: TEST ATTACHMENT
MIME-VERSION: 1.0
CONTENT-DISPOSITION:ATTACHMENT;FILENAME="TEXT_FILE.TXT"
CONTENT-TYPE: TEXT/PLAIN

This JCL is working well, but if I put some text in the body of the USERID.INPUT.CARDS, I don't get the attachment, instead I get the attachment text in the body of the email.

Any help on getting this work, please?

Thanks,
Srini

Re: IEBGENER - jcl to email an attachment

PostPosted: Sat Jun 18, 2011 2:48 pm
by NicC
Have you found anything in the forum to help you? There are many posts re e-mailing attachments - you should find your answer there.

Re: IEBGENER - jcl to email an attachment

PostPosted: Sat Jun 18, 2011 6:27 pm
by Robert Sample
This JCL is working well, but if I put some text in the body of the USERID.INPUT.CARDS, I don't get the attachment, instead I get the attachment text in the body of the email.

Any help on getting this work, please?
What you are seeing is how this form of email attachment works. If there is any text added to the body, the attachment is not going to be attached but rather it will be included in the body of the email. That is the way it works.

The commands below have been used to send an email with text in the body and an attachment:
HELO MAINFRAME
MAIL FROM: <MAINFRAME@xxx.COM>
RCPT TO: <aaa@xxx.COM>
DATA
SUBJECT: PMV ONCALL PRODUCTION LOG - 07/23/2010
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"

--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: INLINE

NOTICE
</BIG></FONT><BR><FONT SIZE=2 FACE=CALIBRI COLOR=RED><I>
THIS E-MAIL (INCLUDING ATTACHMENTS) IS CONFIDENTIAL AND LEGALLY
PRIVILEGED AND IS INTENDED SOLELY FOR THE ADDRESSEE.
THANK YOU FOR YOUR HELP
</I></FONT></CENTER><BR><FONT SIZE=3 FACE=CALIBRI>
THIS IS AN AUTOMATED MESSAGE GENERATED FROM THE MVS JOB XXXXXX
AT ZZZZZZ TO NOTIFY THE USER ABOUT THE DETAILS OF THE PRODUCTION LOG
FOR DIFFERENT JOBS THAT HAVE EXECUTED OVER THE DAY.
<BR><BR>

--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=PROD_LOG.CSV

//         DD   DISP=SHR,DSN=<file to be attached>
//         DD   DISP=SHR,DSN=<trailing period file>
Note that SMTP MIME is extremely sensitive to the precise format of the data, and even omitting on the the blank lines may cause the email to not be sent or the attachment to not be included.

Re: email an attachment

PostPosted: Sun Jun 19, 2011 1:12 am
by Srini Srini
Thanks Robert/Nic, its working now!

- Srini

Re: email an attachment

PostPosted: Sun Jun 19, 2011 2:31 am
by Robert Sample
Good to hear!

Re: email an attachment

PostPosted: Tue Apr 10, 2012 3:24 pm
by mallarapumnaidu
//abcdedgh JOB (xxxxxxx),'Testmail',
//         CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*---------------------------------------------------
//STEPMX05 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=D
//SYSUT2 DD SYSOUT=(B,SMTP)
//SYSUT1 DD DSN=test.EMAIL.ATTACH.CARD,DISP=SHR
// DD DSN=test.EMAIL.ATTACH.CARD1,DISP=SHR
// DD DSN=test.EMAIL.ATTACH.CARD2,DISP=SHR

test.EMAIL.ATTACH.CARD has below information

HELO DCHA
MAIL FROM: <abcd@test.COM>
RCPT TO: <abcd@test.COM>
DATA
FROM: abcd@test.COM
TO: abcd@test.COM
SUBJECT: test fiel.
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: INLINE
NOTICE
</BIG></FONT><BR><FONT SIZE=2 FACE=CALIBRI COLOR=RED><I>
THIS E-MAIL (INCLUDING ATTACHMENTS) IS CONFIDENTIAL AND LEGALLY
PRIVILEGED AND IS INTENDED SOLELY FOR THE ADDRESSEE.
THANK YOU FOR YOUR HELP
</I></FONT></CENTER><BR><FONT SIZE=3 FACE=CALIBRI>
THIS IS AN AUTOMATED MESSAGE GENERATED FROM THE MVS JOB XXXXXX
AT ZZZZZZ TO NOTIFY THE USER ABOUT THE DETAILS OF THE PRODUCTION LOG
FOR DIFFERENT JOBS THAT HAVE EXECUTED OVER THE DAY.
<BR><BR>
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=PROD_LOG.CSV




and test.EMAIL.ATTACH.CARD1 has data to be sent as attachment.



test.EMAIL.ATTACH.CARD2 has

.

My job ran with out any error but i received email but data came as body of email not as attachment.

Even subject is blank.

Please suggest if any changes required in JCL/email card.

Re: email an attachment

PostPosted: Tue Apr 10, 2012 4:47 pm
by Robert Sample
Did you bother doing a search on the other forum you posted the same thing in? If so, you would have found any number of posts that have JCL that generate email attachments, and several discussions about the requirements of SMTP to genrate attachments.

Re: email an attachment

PostPosted: Tue Apr 10, 2012 5:15 pm
by mallarapumnaidu
We tried all possible solutions provided on forums.. its not working for me please review my script and help me ...

Re: email an attachment

PostPosted: Tue Apr 10, 2012 5:26 pm
by Robert Sample
Your search ability needs to be improved, then. I easily and rapidly found on the other forum http://ibmmainframes.com/about55814.html which has a JCL sample that I used to generate an email with attachment and body. You can modify it to meet your needs.

Re: email an attachment

PostPosted: Wed Apr 11, 2012 12:29 pm
by mallarapumnaidu
//abcdTEST JOB (xxx),'test file',
//         CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*---------------------------------------------------
//STEP01S  EXEC PGM=IEBGENER
//SYSOUT   DD SYSOUT=*
//SYSLIST  DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUT2   DD SYSOUT=(B,SMTP),
//*            DCB=(RECFM=FBA,LRECL=267,BLKSIZE=0)
//SYSIN    DD DUMMY
/*
//SYSUT1   DD DSN=abcd.TEST.EMLLIST2,DISP=SHR
//         DD DSN=abcdEMIAL.TEST.ATTCH,DISP=SHR
//         DD DSN=abcd.TEST.EMLLIST3,DISP=SHR


abcd.TEST.EMLLIST2 has below information

HELO DCHA
MAIL FROM: <test@abcd.COM>
RCPT TO: <test@abcd.COM>
DATA
SUBJECT: test FILE
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY
NAD FILE TO SFDC
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=NAD_FILE.CSV


abcd.TEST.EMLLIST3 has a . in it
I am still not able to send attachment i tired using you code given in
http://ibmmainframes.com/about55814.html
I am receiving mail with attachment file data in Body with out subject
Please help me..