SMTPMailService Example

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

Function Options(*DIRECT)

*

Define Field(#TEXT) Type(*CHAR) Length(80)

Define Field(#CNTRL) Type(*CHAR) Length(1)

Def_List Name(#LST) Fields(#TEXT #CNTRL) Type(*WORKING)

*

* JSMX_BEGIN

*

Use Builtin(JSMX_BEGIN)

*

* JSMX_OPEN

*

Use Builtin(JSMX_OPEN) With_Args('LOCALHOST:7560') To_Get(#JSMXSTS #JSMXMSG #JSMXHDLE1)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* SERVICE_LOAD

*

#JSMXCMD := 'SERVICE_LOAD SERVICE(SMTPMailService) TRACE(*YES)'

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* SET SERVER

*

#JSMXCMD := 'SET SERVER(10.2.0.200) USER(testuser) PASSWORD(testuser)'

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* SET ADDRESS

*

#JSMXCMD := 'SET TO([email protected]) FROM([email protected]) SUBJECT(Test Subject)'

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* SEND

*

#TEXT := 'Line 1'

#CNTRL := ''

Add_Entry To_List(#LST)

#TEXT := 'Line 2'

#CNTRL := ''

Add_Entry To_List(#LST)

*

#JSMXCMD := 'SEND'

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG #LST)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* SERVICE_UNLOAD

*

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 'SERVICE_UNLOAD') To_Get(#JSMXSTS #JSMXMSG)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* JSMX_CLOSE

*

Use Builtin(JSMX_CLOSE) With_Args(#JSMXHDLE1) To_Get(#JSMXSTS #JSMXMSG)

Execute Subroutine(CHECK) With_Parms(#JSMXSTS #JSMXMSG)

*

* JSMX_END

*

Use Builtin(JSMX_END)

*

* SUB ROUTINES

*

Subroutine Name(CHECK) Parms((#JSMXSTS *RECEIVED) (#JSMXMSG *RECEIVED))

*

If Cond('#JSMXSTS *NE OK')

*

Use Builtin(JSMX_CLOSE) With_Args(#JSMXHDLE1) To_Get(#JSMXSTS #JSMXMSG)

*

Menu Msgtxt('Java service error has occurred')

*

Endif

*

Endroutine