Page 1 of 1

Send attachement in email using CICS.

Posted: Thu Feb 08, 2018 6:25 pm
by Dino
hi,

I know that we can send an email using mainframe in batch but can we send an email with an attachment using a CICS transaction? If we can do that, how can we do that? Please share your suggestion.

Re: Send attachement in email using CICS.

Posted: Thu Feb 08, 2018 9:12 pm
by Robert Sample
You need a TDQ in the CICS region that points to the internal reader (or use the CICS SPOOL interface commands). Your CICS program copies the batch JCL to the spool (or TDQ) and closes it (for TDQ) or uses SPOOLCLOSE. The batch JCL includes the usual copy to SMTP with the correct format for the attachment and boundaries and the rest of the email. The batch JCL could be hard-coded in the program or it could be read from a VSAM data set. Note that the manuals indicate putting more than 1000 lines of JCL into the spool could cause performance issues for the region (which would include all other users of that region).

Re: Send attachement in email using CICS.

Posted: Mon Feb 12, 2018 12:13 pm
by Dino
Robert Sample wrote: Thu Feb 08, 2018 9:12 pmYou need a TDQ in the CICS region that points to the internal reader (or use the CICS SPOOL interface commands). Your CICS program copies the batch JCL to the spool (or TDQ) and closes it (for TDQ) or uses SPOOLCLOSE. The batch JCL includes the usual copy to SMTP with the correct format for the attachment and boundaries and the rest of the email. The batch JCL could be hard-coded in the program or it could be read from a VSAM data set. Note that the manuals indicate putting more than 1000 lines of JCL into the spool could cause performance issues for the region (which would include all other users of that region).
Thanks. So I shall have a COBOL CICS program having the entire JCL in it which it will copy to TDQ?

Re: Send attachement in email using CICS.

Posted: Mon Feb 12, 2018 6:11 pm
by Robert Sample
So I shall have a COBOL CICS program having the entire JCL in it which it will copy to TDQ?
Not necessarily -- reread my response. Your COBOL program could read a VSAM data set that has the JCL stored in it and copy that JCL to the TDQ. Or, you could use the EXEC CICS SPOOLOPEN, SPOOLWRITE, SPOOLCLOSE commands from the API.

Re: Send attachement in email using CICS.

Posted: Mon Jul 02, 2018 12:15 pm
by Dino
Thanks Robert. I have not worked on this requirement as it was dropped and I could not follow up in this. I had been searching for an example where VSAM file can have a JCL and copy it to TDQ but I could not get one. How exactly this is done actually? We just create a VSAM, have just one record in it which is JCL to send the email? Is this correct?

Re: Send attachement in email using CICS.

Posted: Mon Jul 02, 2018 3:37 pm
by nicc
A valid JCL is going to have more than one record. For example, it will contain at least a jobcard (probably spanning more than one record) and an exec statement (possibly spanning more than one record) and, possibly, a variety of DD statements (each probably spanning several records).

Re: Send attachement in email using CICS.

Posted: Mon Jul 02, 2018 4:56 pm
by Robert Sample
I've seen this done two ways -- where the key of the KSDS is just a sequence number, and where the key of the KSDS is job name + sequence number (this application had multiple jobs that could be submitted from CICS). Each line (record) of JCL is stored in the KSDS as a separate record with its own unique sequence number. It is easiest when the entire 80-byte JCL record is stored in the KSDS. The CICS program reads each record of the KSDS sequentially (by job name if job name is part of the key), strips off the key, and writes the remaining part of the record to the TDQ. Changes to the JCL are usually accomplished by doing a delete / define of the KSDS.

Re: Send attachement in email using CICS.

Posted: Tue Jul 03, 2018 3:54 pm
by Dino
Robert Sample wrote: Mon Jul 02, 2018 4:56 pmI've seen this done two ways -- where the key of the KSDS is just a sequence number, and where the key of the KSDS is job name + sequence number (this application had multiple jobs that could be submitted from CICS). Each line (record) of JCL is stored in the KSDS as a separate record with its own unique sequence number. It is easiest when the entire 80-byte JCL record is stored in the KSDS. The CICS program reads each record of the KSDS sequentially (by job name if job name is part of the key), strips off the key, and writes the remaining part of the record to the TDQ. Changes to the JCL are usually accomplished by doing a delete / define of the KSDS.
Thank you so much Robert. I shall try it now.