Page 1 of 1

Can we call IEBGENER from COBOL?

Posted: Sun Nov 23, 2014 10:09 am
by Raj Mainframe
Hi,

I've used IEBGENER in JCL to send an email. Though now, I'd like to send an email from a COBOL program. Is calling IEBGENER possible? Or is there any another way one can send an email from within a COBOL program?

Thanks.

Re: Can we call IEBGENER from COBOL?

Posted: Sun Nov 23, 2014 2:29 pm
by William Collins
When you are sending an e-mail. IEBGENER is doing nothing special, just copying an input file to an output file. If you define a DDname in the JCL with the same characteristics as the output file in IEBGENER then write to that file you will "send an e-mail from COBOL".

Persoanlly, I'd not want that done. I'd just write to a file and then have something copy it for e-mailing later. Makes lots of things more simple. Usring rings up and says "sorry, I deleted that e-mail, can you send it again?" and you say "sure, let me just restore the data which was updated, and give it an hour or so".

Re: Can we call IEBGENER from COBOL?

Posted: Sun Nov 23, 2014 9:01 pm
by Robert Sample
As stated, you don't need to use IEBGENER -- merely define a file in COBOL, open it for output, write the SMTP (assuming you are using SMTP) commands to that file, and when you close it SMTP will get the email to process. The DD statement in your JCL will be the same as your IEBGENER SYSUT2 (but don't call it SYSUT2 in your COBOL program -- probably would be okay, but I would want to test a bit before using it in a COBOL program since COBOL uses SYSUTn statements for compiler things).

As pointed out, you'll need to consider the need for restart should the email not be delivered, or need to be delivered to a different email address. I would probably place the SMTP commands in an input data set to make it easier to change the email characteristics.

Re: Can we call IEBGENER from COBOL?

Posted: Wed Dec 03, 2014 3:37 pm
by Raj Mainframe
Thanks William and Robert.
...when you close it SMTP will get the email to process.
I don't follow this statemment. Just merely closing the file will get e-mail across? is it?

Re: Can we call IEBGENER from COBOL?

Posted: Wed Dec 03, 2014 5:26 pm
by Robert Sample
SMTP won't process the email until the file is closed (and hence fully available). As long as your SMTP commands in the file are properly formatted, SMTP handles the details of sending the email.

Note that in general mainframe data sets that are open by a program may have records written by the program that will not be available to other programs until the data set is closed. This is not unique to SMTP.