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:
MAIL FROM: <MAINFRAME@xxx.COM>
RCPT TO: <aaa@xxx.COM>
SUBJECT: PMV ONCALL PRODUCTION LOG - 07/23/2010
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"
</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.
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.