SMTPService Example

This example requires the code to be adjusted and server and email address values to be supplied.

FUNCTION   OPTIONS(*DIRECT)

**********

DEFINE     FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(20)

DEFINE     FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

DEFINE     FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

**********

DEFINE     FIELD(#TEXT)   TYPE(*CHAR) LENGTH(80)

DEFINE     FIELD(#CNTRL)  TYPE(*CHAR) LENGTH(1)

DEF_LIST   NAME(#LST) FIELDS((#TEXT) (#CNTRL)) TYPE(*WORKING)

**********

********** JSM_OPEN

**********

USE        BUILTIN(JSM_OPEN) WITH_ARGS('LOCALHOST:7560') TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SERVICE_LOAD

**********

CHANGE     FIELD(#JSMCMD) TO('SERVICE_LOAD SERVICE(SMTPMailService) TRACE(*YES)')

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SET SERVER

**********

CHANGE     FIELD(#JSMCMD) TO('''SET SERVER(10.2.0.200) USER(testuser) PASSWORD(testuser)''')

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SET ADDRESS

**********

CHANGE     FIELD(#JSMCMD) TO('''SET TO([email protected]) FROM([email protected]) SUBJECT(Test Subject)''')

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SEND

**********

CHANGE     FIELD(#TEXT) TO('''Line 1''')

CHANGE     FIELD(#CNTRL) TO(*BLANK)

ADD_ENTRY  TO_LIST(#LST)

CHANGE     FIELD(#TEXT) TO('''Line 2''')

CHANGE     FIELD(#CNTRL) TO(*BLANK)

ADD_ENTRY  TO_LIST(#LST)

**********

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SEND SERVICE_LIST(TEXT,CNTRL)') TO_GET(#JSMSTS #JSMMSG #LST)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SERVICE_UNLOAD

**********

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_UNLOAD') TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** JSM_CLOSE

**********

USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SUB ROUTINES

**********

SUBROUTINE NAME(CHECK) PARMS((#JSMSTS *RECEIVED) (#JSMMSG *RECEIVED))

**********

IF         COND('#JSMSTS *NE OK')

DISPLAY    FIELDS((#JSMSTS) (#JSMMSG))

**********

USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)

**********

MENU       MSGTXT('Java service error has occurred')

**********

ENDIF

**********

ENDROUTINE