How should I configure email address in as400 application?
http://www-912.ibm.com/s_dir/slkbase.nsf/slkbase
In particular, document 13931727, Set Up SMTP (TCP/IP) Mail, is useful. The remainder of this document is in the form of notes made when configuring SMTP mail on an AS/400. The requirement that we had was for the AS/400 to send interface files to a third party using SMTP mail, there was no requirement for the AS/400 to receive mail and, I was told, this would have required a change in the mail gateway at our corporate HQ. Generally, Microsoft Exchange was used as the mail server for the business, and the AS/400 therefore had to link to the outside world through this. Configuring SMTP To access the SMTP configuration menu, you need to do the following: GO CFGTCP Select option '20' (Configure TCP/IP applications) Select option '12' (Configure SMTP) This gives a new menu from which you will need to look at options 3, 10 and 12. CHGSMTPA (Change SMTP Attributes) The important things we found were to ensure that the Mail Router was defined as our MS Exchange Server (HDWINEX1) and that the Firewall setting was flagged as *YES. Both of these parameters are found by paging down to the second display within the CHGSMTPA command. ADDDIRE (Add Directory Entry) You need to ensure that a directory entry exists for the Internet SMTP router. We also have one for our MS Exchange server, but I can't remember if this was a hangover from the many attempts we made at configuring SMTP on the AS/400. Configure Distribution Services Select option 12 from the Configure TCP/IP SMTP menu and the following screen is displayed.
You will need to access options 1 and 2 to configure a distribution queue and a routing table entry for SMTP to work. Selecting option 1 allows a distribution queue to be configured. The queue name that needs to be set up is QSMTPQ which should have the following parameters. Paging down allows the number of retries, etc to be set. The defaults for these values can be taken. Returning to the mini-menu, option 2 allows the routing table to be maintained. A routing table entry should be set up for TCP/IP with the following attributes: CHGPOPA (Change POP Attributes) We had a problem with attachments being MIME encoded due to their size when sent. The Message Split Size shown in the CHGPOPA display allows you to set a maximum message size to be reached before MIME encoding takes place. The default is 32 KB which we found to be way too small for our interfaces and have placed a 2MB limit on the file instead. It is possible to prevent MIME encoding for files larger than 2MB and an IBM Knowledge Base document can be found at the following URL: http://as400service.ibm.com/supporthome.nsf/document/10000051 CHGDSTA (Change Distribution Attributes) The distribution attributes need to be changed to identify the Internet SMTP route to be used. There should also be a Directory entry for this. STRMSF (Start Mail Server Framework) and ENDMSF (End Mail Server Framework) Mails are sent using the Mail Server Framework and the commands required to start and stop this service are STRSMF and ENDMSF. The STRSMF allows you specify the number of channels to start and you should set this according to the expected number of e-mails you are going to send. We have kept the default at 3 jobs. All MSF jobs are run under user QMSF. SNDDST (Send Distribution Message) To send messages using SMTP, the SNDDST command should be used. Messages can be sent either as standard free format text, or as attachments. The following commands are examples for both: Example 1: Sending an attached document from a shared folder SNDDST TYPE(*DOC) TOINTNET('jonathan.mason@Astradyne-uk.com') DSTD(Interface File - New Memberships') MSG('Any problems contact the Help-Desk on +44 1252 400955') DOC('H0900123.csv') FLR('HOGTRANS/ASSIST') Example 2: Sending a free format message SNDDST TYPE(*LMSG) TOINTNET('jonathan.mason@Astradyne-uk.com') DSTD('Test e-mail') LONGMSG('Test e-mail sent from AS/400.') DOCD('Test e-mail') SUBJECT('AS/400 Test') As we used the e-mail service for sending interface files, we always used the *DOC message types as shown in the first example. The following CL program is an example of how we used the e-mail facility to send interface files to third parties: /****************************************************************/ /* */ /* A S T R A D Y N E ( U K ) L T D */ /* */ /* 4 Knoll Road, Fleet, Hampshire. GU51 4PR */ /* */ /* Tel: 01252 400955 Fax: 01252 400956 */ /* */ /****************************************************************/ /* */ /* H A R L E Y O W N E R S G R O U P */ /* M E M B E R S H I P D A T A B A S E */ /* */ /****************************************************************/ /* (C) Astradyne (UK) Ltd, 1999 */ /****************************************************************/ /* */ /* PROGRAM DESCRIPTION */ /* */ /* Program : J57H09 */ /* */ /* Written By : Jonathan Mason Date: 15/06/99 */ /* */ /* Description: Produces a PC style file containing the New */ /* Members List for transmission to HA... */ /* */ /* */ /*À Parameters : *NONE */ /* */ /* */ /* */ /****************************************************************/ /* */ /* PROGRAM AMENDMENTS */ /* */ /* Ref By Date Description */ /* */ /* EMAIL JDM 31/07/00 Added processing to allow file to */ /* be sent by email automatically... */ /* */ /* / / */ /* */ /* */ /* */ /* */ /****************************************************************/ PGM PARM() DCL VAR(&CNT) TYPE(*CHAR) LEN(6) DCL VAR(&CNTD) TYPE(*DEC) LEN(6) DCL VAR(&DAT) TYPE(*CHAR) LEN(6) DCL VAR(&DATJ) TYPE(*CHAR) LEN(5) DCL VAR(&DSERR) TYPE(*CHAR) LEN(244) VALUE(*BLANK) DCL VAR(&DTAARA) TYPE(*CHAR) LEN(10) VALUE('D57H09') DCL VAR(&FILE) TYPE(*CHAR) LEN(12) DCL VAR(&JOBID) TYPE(*CHAR) LEN(10) DCL VAR(&LABELS) TYPE(*CHAR) LEN(20) DCL VAR(&LOCK) TYPE(*CHAR) LEN(1) DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(160) DCL VAR(&PGMID) TYPE(*CHAR) LEN(10) VALUE('P57H09') DCL VAR(&TIME) TYPE(*CHAR) LEN(8) DCL VAR(&TYPE) TYPE(*CHAR) LEN(1) DCL VAR(&USER) TYPE(*CHAR) LEN(10) DCL VAR(&BLANK) TYPE(*CHAR) LEN(244) + VALUE('P57H09 - + 00000000 + 000000000000000000000000000000000000 - - 000000 ') DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(5000) /* EMAIL */ DCL VAR(&CC1MAIL) TYPE(*CHAR) LEN(128) /* EMAIL */ DCL VAR(&CC2MAIL) TYPE(*CHAR) LEN(128) /* EMAIL */ DCL VAR(&PRIMAIL) TYPE(*CHAR) LEN(128) /* 0000 - Initialise all work fields... */ CALL PGM(JHOGLIBL) PARM('ADD') CHGVAR VAR(&DSERR) VALUE(*BLANK) RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DAT) RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIME) CVTDAT DATE(&DAT) TOVAR(&DATJ) FROMFMT(*SYSVAL) + TOFMT(*JUL) TOSEP(*NONE) RTVJOBA JOB(&JOBID) USER(&USER) /* 0010 - Identify the controlling data area and determine whether or not the */ /* - interface can be run yet or if the last one completed normally... */ RTVDTAARA DTAARA(&DTAARA (15 1)) RTNVAR(&LOCK) IF COND(&LOCK *EQ 'L') THEN(DO) CHGVAR VAR(&DSERR) VALUE(&BLANK) CHGVAR VAR(%SST(&DSERR 230 5)) VALUE(&DATJ) CHGVAR VAR(%SST(&DSERR 235 8)) VALUE(&TIME) CHGVAR VAR(%SST(&DSERR 219 10)) VALUE(&JOBID) CHGVAR VAR(%SST(&DSERR 21 80)) VALUE('TRANSACTION + ALREADY ACTIVE AND LOCKED') CALL PGM(P570ER) PARM(&DSERR) GOTO CMDLBL(EOJ) ENDDO CHGDTAARA DTAARA(&DTAARA (15 1)) VALUE('L') /* 0020 - Retrieve the interface counter... */ CALL PGM(J57RTVFSEQ) PARM(&DTAARA &CNT) /* 0030 - Position to the start of the open query file and create the PC */ /* - file... */ MONMSG MSGID(CPF0000) CALL PGM(P57H09) PARM(&CNT) /* 0035 - Prepare to email the file to the fulfilment house... */ /* EMAIL */ RTVDTAARA DTAARA(H09MAIL) RTNVAR(&PRIMAIL) /* EMAIL */ RTVDTAARA DTAARA(CC1MAIL) RTNVAR(&CC1MAIL) /* EMAIL */ RTVDTAARA DTAARA(CC2MAIL) RTNVAR(&CC2MAIL) /* EMAIL */ CPYTOIMPF FROMFILE(F57H09) TOFILE(H09FIXED) MBROPT(*REPLACE) /* 0040 - Move the file to the HOGTRANS folder. The network path for the */ /* - file is: \\S44CB915\QDLS\HOGTRANS\ASSIST\H08xxxxx.CSV */ CHGVAR VAR(&FILE) VALUE('H09' *CAT %SST(&CNT 2 5) *CAT '.CSV') /* EMAIL */ CPYTOPCD FROMFILE(H09FIXED) TOFLR('HOGTRANS/ASSIST') + TODOC(&FILE) REPLACE(*YES) TRNTBL(QASCIIMAIL) CHGVAR VAR(&MSGTXT) VALUE('ATTENTION: Interface H08 has + completed and the output file can be found in + \\S44CB915\QDLS\HOGTRANS\ASSIST\' *CAT &FILE) SNDMSG MSG(&MSGTXT) TOUSR(&USER) /* 0050 - Save the interface file to library SAVETRANS... */ CPYF FROMFILE(F57H09) TOFILE(QTEMP/F57H09COPY) + MBROPT(*REPLACE) CRTFILE(*YES) CALL PGM(J57SAVEIFC) PARM('H09' 'F57H09COPY' &CNT) /* 0055 - Now email the file to the fulfilment house... */ /* EMAIL */ IF COND(&PRIMAIL *NE '*NONE') THEN(DO) /* EMAIL */ SNDDST TYPE(*DOC) TOINTNET((&PRIMAIL) (&CC1MAIL *CC) (&CC2MAIL *CC)) + DSTD('HOG Assistance - New Memberships') + MSG('If you find any problems with the attached file, + please contact the Harley-Davidson Europe IS + Help-Desk on +44 (0) 1753 829599 or send an email to the + ''cc'' addressees shown above.') DOC(&FILE) + FLR('HOGTRANS/ASSIST') /* EMAIL */ ENDDO /* 00060 - Finally, clear the member used for the extract and reset the data */ /* - area... */ CLRPFM FILE(F57H09) CHGDTAARA DTAARA(&DTAARA (13 2)) VALUE('OK') CHGDTAARA DTAARA(&DTAARA (15 1)) VALUE(' ') EOJ: ENDPGM In the above program, the lines shown highlighted handle the e-mailing of the file. The e-mail addresses are picked up from data areas, and the AS/400 interface data is copied to a fixed length file and commas inserted using the CPYTOIMPF command. This command creates a comma separated file on the AS/400 which is then placed in a shared folder using the CPYTOPCD command. The email address is checked to see if the file is to be sent, and if so the SNDDST command mails the *.csv file from the shared folder.
0 comments:
Post a Comment