PreviousNext
Help > Programmation avec LAUNCHER Office > Programmation avancée > Exemples de programmes CL > Exemple de mail
Exemple de mail

 La commande MAILSEND est un programme en CL qui montre l’élaboration d’un mail avec un fichier attaché et un niveau de priorité élevé.

Vous pouvez éditer le source depuis le fichier QCLSRC de la bibliothèque LAUNCHER et remplacer les paramètres par défaut avec les votres.

 

Les valeurs par défaut sont les suivantes :

            CHGVAR      VAR(&ADDR) VALUE('INFO@THECOMPAGNY.COM')

            CHGVAR      VAR(&SUBJ) VALUE('THE CUSTOMER LIST')

            CHGVAR      VAR(&MESG) VALUE('Hello,%PARA%%PARA%Here +

                        is the list of the customers you +

                        required. The file comes from our AS/400. +

                        Isn''t this great ?%PARA%%PARA%See you +

                        soon !')

 

Source de l’exemple

 

/* VARIABLES USED TO OPEN COMMUNICATION AND SEND COMMANDS ...*/              PGM                                                

             DCL        VAR(&HANDLE) TYPE(*CHAR) LEN(50) VALUE('*ONLY')     

             DCL        VAR(&SVRADDR) TYPE(*CHAR) LEN(30) VALUE('*DEV')     

             DCL        VAR(&CCSID) TYPE(*CHAR) LEN(10)  VALUE('*JOB')      

             DCL        VAR(&CMD) TYPE(*CHAR) LEN(10)           

             DCL        VAR(&OPT) TYPE(*CHAR) LEN(1)            

             DCL        VAR(&PARM1) TYPE(*CHAR) LEN(512)        

             DCL        VAR(&PARM2) TYPE(*CHAR) LEN(1024)       

             DCL        VAR(&RESULT) TYPE(*CHAR) LEN(512)       

             DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)          

             DCL        VAR(&MSG1) TYPE(*CHAR) LEN(80)          

             DCL        VAR(&MSG2) TYPE(*CHAR) LEN(80)          

/* VARIABLES FOR THE MAIL */                                    

             DCL        VAR(&ADDR) TYPE(*CHAR) LEN(64)          

             DCL        VAR(&SUBJ) TYPE(*CHAR) LEN(64)          

             DCL        VAR(&MESG) TYPE(*CHAR) LEN(512)         

                                                                

             CHGVAR     VAR(&ADDR) VALUE('INFO@THECOMPAGNY.COM')

             CHGVAR     VAR(&SUBJ) VALUE('THE CUSTOMER LIST')         

             CHGVAR     VAR(&MESG) VALUE('Hello,%PARA%%PARA%Here +    

                          is the list of the customers you +          

                          required. The file comes from our AS/400. + 

                          Isn''t this great ?%PARA%%PARA%See you +    

                          soon !')                                    

 

/* OPEN THE SESSION */                                                

             CALL       PGM(LNCOPEN) PARM(&HANDLE &SVRADDR &CCSID)    

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))       

/* CONNECT TO THE SERVER ...*/                                        

 

/* MESSAGE IS SENT TO RECIPIENT &ADDR */                              

/* SUBJECT IS &SUBJ AND MESSAGE IS &MESG */                           

/* */                                                                 

             CHGVAR     VAR(&CMD) VALUE('MAILPREP')                   

             CHGVAR     VAR(&PARM1) VALUE(&ADDR)                      

             CHGVAR     VAR(&PARM2) VALUE(&SUBJ)                      

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +   

                                         &PARM2 &RESULT)              

             IF         COND(%SST(&RESULT 1 5) =

             SNDMSG     MSG(&RESULT) TOUSR(QPGMR)                  

 SUI:                                                               

 /* TRANSFER THE SP_CUST FILE AND ATTACH IT TO THE MAIL  */         

             CHGVAR     VAR(&CMD) VALUE('DBFXFER')                 

             CHGVAR     VAR(&PARM1) VALUE('%LNCDIR%\SAMPLES\SP_CUST.TXT')      

             CHGVAR     VAR(&PARM2) VALUE('LAUNCHER/SP_CUST')      

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

                        &PARM2 &RESULT)           

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))    

                                                                  

 /* ATTACH THE FILE */                                              

             CHGVAR     VAR(&CMD) VALUE('MAILATT')                 

             CHGVAR     VAR(&PARM1) VALUE('%LNCDIR%\SAMPLES\SP_CUST.TXT')      

             CHGVAR     VAR(&PARM2) VALUE(' ')                     

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

                        &PARM2 &RESULT)           

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))    

 /* SET THE MESSAGE BODY */                                         

             CHGVAR     VAR(&CMD) VALUE('MAILTEXT')                

             CHGVAR     VAR(&PARM1) VALUE(&MESG)                   

             CHGVAR     VAR(&PARM2) VALUE(' ')                   

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +          

                        &PARM2 &RESULT)         

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))  

/* SET THE PRIORITY */                                           

             CHGVAR     VAR(&CMD) VALUE('MAILPRTY')              

             CHGVAR     VAR(&PARM1) VALUE('*HIGH')               

             CHGVAR     VAR(&PARM2) VALUE(' ')                   

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +          

                        &PARM2 &RESULT)         

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))  

                                                                 

/* SEND THE MESSAGE */                                           

             CHGVAR     VAR(&CMD) VALUE('MAILSEND')              

             CHGVAR     VAR(&PARM1) VALUE(' ')                   

             CHGVAR     VAR(&PARM2) VALUE(' ')                   

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +          

                        &PARM2 &RESULT)         

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))  

             CHGVAR     VAR(&CMD) VALUE('MAILEND')          

             CHGVAR     VAR(&PARM1) VALUE(' ')              

             CHGVAR     VAR(&PARM2) VALUE(' ')              

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +     

                        &PARM2 &RESULT)    

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))         

CLOSE:                                                      

/* END OF COMMUNICATION WITH THE SERVER STATION ... */      

             CHGVAR     VAR(&CMD) VALUE('END ')             

             CHGVAR     VAR(&PARM1) VALUE(' ')              

             CHGVAR     VAR(&PARM2) VALUE(' ')              

             CALL       PGM(LNCCMD) PARM(&HANDLE &CMD &OPT +

                        &PARM1 &PARM2 &RESULT)            

             MONMSG     MSGID(LNC0000) EXEC(GOTO CMDLBL(ERROR))         

             GOTO END                                       

                                                            

ERROR:                                                      

             CALL       PGM(LNCCLOSE) PARM(&HANDLE)         

             RCVMSG     MSG(&MSG1) SECLVL(&MSG2) MSGID(&MSGID)          

             SNDPGMMSG  MSGID(CPF9898) MSGF(QSYS/QCPFMSG) +   

                        MSGDTA('ERROR !!!!!! ' *CAT &MSGID *CAT ' +       

                        ' *CAT &MSG1 *CAT ' ' *CAT &MSG2) +   

                        MSGTYPE(*ESCAPE)                      

                        GOTO CLOSE                            

END:                                                          

             ENDPGM