IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Trigger a mail step for every record in the Input file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pawan_kch

New User


Joined: 05 Apr 2006
Posts: 11
Location: Bangalore

PostPosted: Mon Dec 26, 2011 2:57 pm
Reply with quote

Hi, Do we have any JCL to trigger a mail step reading every record in the input file using a loop.

Lets say my input file is like this,
Code:

EMP MAIL        MANAGER MAIL
------------    ------------
emp1@abc.com    mgr1@abc.com
emp2@abc.com    mgr2@abc.com
emp3@abc.com    mgr1@abc.com
emp4@abc.com    mgr1@abc.com
emp5@abc.com    mgr2@abc.com


The mail-format is same for all the employees, but the records may vary for every run. I want to send a mail to each employee and cc'ing to his manager.

I dont want to send this mail to all employees in the input dataset at once. when a mail is received, the employee should not see other employee/manager details who are all copied in this mail.

Any suggestions/help, please advise me.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Dec 26, 2011 3:08 pm
Reply with quote

Are these hapless managers aware that you are going to start filling their mailboxes with copies of identical messages, so that they can diligently file them in individual employee folders?

Doesn't sound like a good plan to me, but if it is what they want, then OK.

Have you looked at the possibility of using BCC?

If that is no use to you, you're going to have to go back to thinking. There are no loops in JCL. You'll need a program/utility of some sort to build the e-mails.

Plus if you use CC, the employee will see the CC, so you have a self-defeating requirement you need to sort out.

You might want to consider a "mailing list". One mail in, repeated to all recipients. The managers wouldn't know who had individually received the e-mail without some process to check, but I don't believe they'll be ecstatic about automatically-stuffed inboxes from your original solution anyway, so nail-down the requirement first.
Back to top
View user's profile Send private message
Soumik Das

New User


Joined: 06 Aug 2011
Posts: 25
Location: India

PostPosted: Tue Dec 27, 2011 6:15 pm
Reply with quote

Quote:
nail-down the requirement first


Agree with Bill here..

But just going ahead of myself...I am just posting two of the many possible solutions here (these are the ones we use in our IT house for automated emails from HOST servers).

--> Possibilities are you will be using some utitlity like MEMOAPI to send ur emails. In that case for multiple emails the JCL has to be invoked multiple number of times. For this you can use a REXX or CLIST to read details from the file and push these details into a CARDLIB member which will be then used as parameters to the utility when the JCL is submitted via the TSO SUBMIT command. See here for further details

--> In case you want to use a REXX/CLIST or a COBOL or PLI program the steps that you should take are

1. Allocate a file which will be routed via the DEST option to the SMTP sever(in COBOL or PLI you would have to use the TSOLNK service routine...for more detail check here). For e.g.

Code:
ALLOCATE FILE(MAILDS) SYSOUT(A) DEST(SMTP1) REUSE RECFM(V,B) LRECL(1004) BLKSIZE(0)


Please note you would have to ask the admin guys to configure the DEST and the SYSOUT class properly.

2. Write the following data into the MAILDS file after substituting the to and bcc with the data read from the input file. The following lines can be used say if you are sending a friendly message like "Have a nice day".

Code:

HELO <identifier>
MAIL FROM: sender@abc.com
RCPT TO: xyz@abc.com
DATA
FROM: sender@abc.com
TO: xyz@abc.com
BCC: abc@abc.com
SUBJECT:Goodday!
MIME-Version:1.0
Content-type: text/html
<HTML>
<BODY BGCOLOR=#FFFFFF>
<P><FONT FACE="Arial" COLOR=#000000>
Hi,<BR>
Have a nice day!.<BR>
Regards,<BR>
Sender
</P>
</FONT>
</BODY>
</HTML>


3. Free the file. Use the command
Code:
FREE FILE(MAILDS)


4. repeat steps 1-3 for all records in input file.

I believe this has some information that will allow you to go forward..
Back to top
View user's profile Send private message
rajesh1183

New User


Joined: 07 Jan 2008
Posts: 98
Location: Hyderabad

PostPosted: Tue Dec 27, 2011 7:11 pm
Reply with quote

Assuming the below JCL is in THIS.JCL.PDS(EMAIL) PDS,
Code:

//STEP01  EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*
//SYSPRINT  DD SYSOUT=*
//SORTIN    DD DSN=EMAIL.FILE,DISP=SHR
//SORTOF1   DD DSN=FILE1,DISP=SHR
//SORTOF2   DD DSN=FILE2,DISP=SHR
//SYSIN     DD *                         
 SORT FIELDS=COPY                       
 OUTFILE FILES=1,STARTREC=1,ENDREC=1
 OUTFILE FILES=2,STARTREC=2         
/*
//*
//STEP02  EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*
//SYSPRINT  DD SYSOUT=*
//SORTIN    DD DSN=FILE2,DISP=SHR
//SORTOUT   DD DSN=EMAIL.FILE,DISP=SHR
//SYSIN     DD *                         
 OPTION COPY                       
/*
//*
//EMAIL SENDING CODE using FILE1 email-id
//*
//STEP04  EXEC PGM=IDCAMS
//SYSOUT    DD SYSOUT=*
//SYSPRINT  DD SYSOUT=*
//INFILE    DD DSN=FILE2,DISP=SHR
//SYSIN     DD *
 PRINT INFILE(INFILE) COUNT(1)
 *FILE IS EMPTY
 IF LASTCC EQ 4
    SET MAXCC EQ 2
//*
//STEP05  EXEC PGM=IEBGENER,COND=(2,EQ,STEP03)
//SYSOUT    DD SYSOUT=*
//SYSPRINT  DD SYSOUT=*
//SYSIN     DD DUMMY
//SYSUT1    DD DSN=THIS.JCL.PDS(EMAIL),DISP=SHR
//SYSUT2    DD SYSOUT=(A,INTRDR)
//*


the above is one sol. if ur shop allows INTRDR. But, the above sol. is limited if you have very less no. of employees as this is going to submit the same job until your email file is empty... NOT AN OPTIMAL solution but a SOLUTION...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top