> f you allocate a DD in your JCL with SYSOUT going to SMTP, and specify 
> FREE=CLOSE,
> then your emails will be sent to SMTP when you close the DD in REXX, (EXECIO 
> with FINIS option).
> You can use the same DD over and over as long as you don't FREE it.

Closing it will free it. Also, you really should have SPIN=UNALLOC.

> REUSE lets you use the same DD Name over and over.

You don't need REUSE when you've freed the allocation.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of 
Dale R. Smith [dale-sm...@columbus.rr.com]
Sent: Sunday, May 17, 2020 10:24 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Looking for clarification/guidance on SMTP DD FREE/SPIN

On Fri, 15 May 2020 13:08:40 -0700, Charles Mills <charl...@mcn.org> wrote:

>I am designing a long-running Rexx program that will from time to time
>generate an e-mail via the SMTP server. The idea is to allocate a DD
>SYSOUT=(B,SMTP) and write the SMTP commands to it. I've never done that
>before so I have some questions:
>
>- Am I correct in my assumption that I will have to "spin" the dataset
>before the SMTP server will pick it up?
>- Assuming Yes to the first question, am I correct (a.) that
>FREE=CLOSE,SPIN=UNALLOC on the DD will get the records over to SMTP on
>EXECIO (FINIS; but that (b.) at that point the DD "no longer exists" -- that
>I will get an error if I try to open it again? (Recall the program is
>"long-running" and needs to generate multiple e-mails "from time to time."
>They need to go out more or less as created, not in a big batch later on.)
>- Not a huge deal if so, I guess. I can use BPXWDYN to allocate my DD again
>and again rather than JCL. Anyone have any better ideas?
>
>Thanks. Outside-the-above-box suggestions cheerfully considered. I'm pretty
>much set on Rexx, e-mails, and "long-running with multiple e-mails from time
>to time" but will consider other possibilities.
>
>Charles

I have written several long running REXX Programs that periodically send emails.

If you allocate a DD in your JCL with SYSOUT going to SMTP, and specify 
FREE=CLOSE, then your emails will be sent to SMTP when you close the DD in 
REXX, (EXECIO with FINIS option).  You can use the same DD over and over as 
long as you don't FREE it.

You can also dynamically allocate a file to use to send email like this:
'ALLOCATE DDNAME(yourdd) REUSE SYSOUT',
   'SPIN(UNALLOC) DEST(yournode.SMTP)'
(You probably don't need the Node Name, but it doesn't hurt.  You might need it 
if the Job is submitted from a different node than the one it is running on.  
You can get the node name of the current system in REXX with SYSVAR:  sysnode = 
SysVar('SYSNODE') ).

Write your email to the DD Name you specified with EXECIO, then FREE it when 
you are done.  REUSE lets you use the same DD Name over and over.

--
Dale R. Smith



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to