Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing multiple addresses to SNDDST

Status
Not open for further replies.

Ju5

Programmer
May 25, 2007
85
0
0
PH
Hi,

I need some help with sending an email to multiple users via SNDDST.

My problem involves 2 RPG programs and 1 CL. Below is the part of the CL that is being used to send the email.

SNDDST TYPE(*FILE) TOINTNET((&ADDR)) +
DSTD(NODISTDESC) USRID(*CURRENT) +
DOCFILE(file1) DOCTYPE(*FFT) +
SUBJECT(&SUBJ)

The first RPG(RPG1) program creates the contents of the email(header, receiver, other details) and puts it into EMAILFILE. The RPG program only puts in 1 receiver.

The second RPG(RPG2) program takes the Subject and Receiver from EMAILFILE and passes it to the CL program as &ADDR and &SUBJ.

I've been asked to send a copy of EMAILFILE to 3 other users besides the original receiver. I'm planning to use a mailing group for the 3 users and hardcode the mailing list in the Output Specs of RPG1.

I can't change RPG2 and the CL beyond making &ADDR larger as there are other programs that use it to send email out and the 3 users only need to have a copy of the email generated by RPG1.

What separator do I need to add another recipient to &ADD?


Thanks in advance.
 
To send distribution to more recipients you need to use this form
Code:
SNDDST TYPE(*DOC)
TOINTNET((addr1)
         (addr2)
         ...
         (addrN))
...
Some times ago I created a CL-command to send email to more than one email-addresses. If you want I can post it here for you.
 
Hi mikrom,


Thanks for the reply.

Unfortunately I can't change the CL since it is used by other programs and it is scheduled to run on certain dates. I was hoping to only change RPG1 by adding additional email addresses on it. If I can't think of anything else I guess I'll just have to make another copy RPG2 and the CL specifically for RPG1.
 
Hi Ju5,

Or you can create another CL+CMD, which fullfill, what you need.

Here is what I'm using:
CL-Program SNDMAIL
Code:
/*   Program :  SNDMAIL                           Version 1.0     */
/*   System  :  iSeries     V5Rx                                  */
/*   Author  :  Roman Miklos                      20.4.2007       */
/*                                                                */
/*                                                                */
/*   To compile :                                                 */
/*                                                                */
/*        CRTCLPGM   PGM(XXX/SNDMAIL) SRCFILE(XXX/QCLSRC)         */

 SNDMAIL:    PGM        PARM(&SUBJ &MSG &ADDRLIST &ATTACH &ATTACHMENT)
             /* Program Parameters */
             DCL        VAR(&SUBJ)       TYPE(*CHAR)  LEN(80)
             DCL        VAR(&MSG)    TYPE(*CHAR)  LEN(256)
             DCL        VAR(&ADDRLIST)   TYPE(*CHAR)  LEN(902)
                              /* Length is 30*30+2 = 902 */
             DCL        VAR(&ATTACH)     TYPE(*LGL)
             DCL        VAR(&ATTACHMENT) TYPE(*CHAR)  LEN(24)
             /* Variables */
             DCL        VAR(&CMD)        TYPE(*CHAR)  LEN(2500)
             DCL        VAR(&CMDLEN)     TYPE(*DEC)   LEN(15 5) VALUE(2500)
             DCL        VAR(&FLR)        TYPE(*CHAR)  LEN(12)
             DCL        VAR(&DOC)        TYPE(*CHAR)  LEN(12)
             DCL        VAR(&DSTD)       TYPE(*CHAR)  LEN(30)
             DCL        VAR(&CT)         TYPE(*DEC)   LEN(3 0)
             DCL        VAR(&J)          TYPE(*DEC)   LEN(3 0)
             DCL        VAR(&POS)        TYPE(*DEC)   LEN(3 0)
             DCL        VAR(&ADDR)       TYPE(*CHAR)   LEN(30)

             /* Extract Folder and Document Name */
             CHGVAR     VAR(&DOC)    VALUE(%SST(&ATTACHMENT  1 12))
             CHGVAR     VAR(&FLR)    VALUE(%SST(&ATTACHMENT 13 12))
             CHGVAR     VAR(&DSTD)   VALUE('email')

             /* Build the First Part of the SNDDST Command String */
             IF         COND(&ATTACH *AND (&DOC *NE ' ')) THEN(DO)
                CHGVAR     VAR(&CMD) VALUE('SNDDST TYPE(*DOC) DSTD(' *TCAT +
                             '''' *TCAT &DSTD *TCAT '''' *TCAT ') ' *BCAT +
                             'SUBJECT(' *TCAT '''' *TCAT &SUBJ *TCAT '''' +
                             *TCAT ') ' *BCAT 'MSG(' *TCAT '''' *TCAT &MSG +
                             *TCAT '''' *TCAT ') ' *BCAT 'DOC(' *TCAT &DOC +
                             *TCAT ') ' *BCAT 'FLR(' *TCAT &FLR *TCAT ') +
                             TOINTNET(')
             ENDDO
             ELSE       CMD(DO)
                CHGVAR     VAR(&CMD) VALUE('SNDDST TYPE(*LMSG) DSTD(' +
                             *TCAT '''' *TCAT &DSTD *TCAT '''' *TCAT ') ' +
                             *BCAT 'SUBJECT(' *TCAT '''' *TCAT &SUBJ *TCAT +
                             '''' *TCAT ') ' *BCAT 'LONGMSG(' *TCAT '''' +
                             *TCAT &MSG *TCAT '''' *TCAT ') TOINTNET(')
             ENDDO

             /* Build the Address Part From ADDRLIST  */
             CHGVAR     VAR(&CT)     VALUE(%BIN(&ADDRLIST 1 2))
             CHGVAR     VAR(&J)      VALUE(1)
             CHGVAR     VAR(&POS)    VALUE(3)

             DOWHILE    COND(&J *LE &CT)
                CHGVAR     VAR(&ADDR) VALUE(%SST(&ADDRLIST &POS 30))
                CHGVAR     VAR(&CMD) VALUE(&CMD *TCAT '(' *TCAT &ADDR +
                             *TCAT ') ')
                CHGVAR     VAR(&J)      VALUE(&J + 1)
                CHGVAR     VAR(&POS)    VALUE(&POS + 30)
             ENDDO

             /* Close E-Mail TOINTNET Parameter */
             CHGVAR     VAR(&CMD) VALUE(&CMD *TCAT ')')

             /* Send Distribution */
             CALL       PGM(QCMDEXC) PARM(&CMD &CMDLEN)

 END:        ENDPGM

the Corresponding Command SNDMAIL
Code:
 /*                                                               */
 /*                             \\\\\\\                           */
 /*                            ( o   o )                          */
 /*------------------------oOO----(_)----OOo----------------------*/
 /*                                                               */
 /*  Command : SNDMAIL                          Version 1.00      */
 /*  System :  iSeries                                            */
 /*  Author :  Roman Miklos                     23.4.2007         */
 /*                                                               */
 /*  Send E-Mail using SNDDST                                     */
 /*                                                               */
 /*                                                               */
 /*                     ooooO              Ooooo                  */
 /*                     (    )             (    )                 */
 /*----------------------(   )-------------(   )------------------*/
 /*                       (_)               (_)                   */
 /*                                                               */
 /*  To compile :                                                 */
 /*                                                               */
 /*        CRTCMD     CMD(XXX/SNDMAIL) PGM(XXX/SNDMAIL)           */
 /*                   SRCFILE(XXX/QCMDSRC)                        */
 /*                                                               */

 SNDMAIL:    CMD        PROMPT('Send E-Mail using SNDDST')

 /* Mail Subject */
             PARM       KWD(SUBJ) TYPE(*CHAR) LEN(80) MIN(1) PROMPT('Mail +
                          Subject:')
 /* Mail Message Text*/
             PARM       KWD(MSG) TYPE(*CHAR) LEN(256) MIN(1) PROMPT('Mail +
                          Message:')
 /* List of E-Mail Addresses                                      */
             PARM       KWD(ADDRLIST) TYPE(*CHAR) LEN(30) MIN(1) MAX(30) +
                          CASE(*MIXED) PROMPT('Addresses +
                          (rmiklos@pss.sk):')
 /* Mail with/without Attachement                                 */
             PARM       KWD(ATTACH) TYPE(*LGL) DFT(*NO) SPCVAL((*YES '1') +
                          (*NO '0')) MIN(0) EXPR(*YES) CHOICE('*YES, *NO') +
                          PROMPT('Attachment')
             PARM       KWD(DOC) TYPE(DOC) PMTCTL(ATTACH) PROMPT('Attached +
                          Doc (8.3)')

 /* Prompt Control */
 ATTACH:     PMTCTL     CTL(ATTACH) COND((*EQ '1')) NBRTRUE(*EQ 1)

 DOC:        QUAL       TYPE(*NAME) LEN(12)
             QUAL       TYPE(*GENERIC) LEN(12) DFT(MAIL) PROMPT('Folder +
                          with Attachment')

 
The email contents is created by RPG1 which writes it out to FILE1 in the following format:

Hmyemail@mailer.com
DAttention: myemail
D
Dcontents of my email.

RPG2 reads FILE1, gets the email address(H) and the Subject line(DAttention) and passes it to a 40 length padd and psubj variable which is then passed on to the CL program.

The CL program uses padd as the recipient and psubj for thE subject line. I was hoping to just insert the new addresses into the padd.
 
It sound a little bit complicated. I guess, you use this specfic approach with the FILE1, because you need to write several different emails to several addresses. I use the simple SNDMAIL command (I posted above) to write the same email with attachment to several email adresses, mostly to send a result of an reporting programm to several recipients.

I think, there are about 2 possible ways how to solve you problem:

1. You could modify your RPG1, so it stores to the email address field of the FILE1 more then one email address (if the field is enough long) in the format
Code:
(addr1)(addr2)(addr3)
but then it would be necessary that you modify your CL-program too, because you have now in it
Code:
TOINTNET((&ADDR))
and to feed it with multiple addresses, you need to have this
Code:
TOINTNET(&ADDR)
But as you said, you cannot modify this CL-program, because it is used on another places too.


2. You could modify your RPG1, that it stores multiple addresses in the address field of FILE1 delimited by space, i.e.:
Code:
addr1 addr2 addr3
and then you need to modify your other RPG2 program so that it takes this address list string, splits it in simple addresses and then in the loop for each address calls the CL-program.

 
Ju5 said:
I can't change RPG2 and the CL beyond making &ADDR larger

Broaden and populate &ADDR variable with the 3 recipient addresses

dcl &addr *char 253
chgvar &addr ('(name1@domain.xxx) +
(name2@domain.xxx) +
(name3@domain.xxx)')

or do 3 loops in RPG1 program to send to one recipient at a time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top