Page 1 of 1

Trying to get SMTPMAILSERVICE working

Posted: Wed May 03, 2017 1:29 am
by gstenstrom
Hi,

Following an example and your documentation, I'm not able to send an Email through this service.
Does something need to be running in the background on our iSeries?
I tried both the iSeries IP address and our Mail router ip addess, still no luck.

It appears each BIF runs okay except for the last unload - 'SERVICE_UNLOAD' where it says the "Invalid JSMX handle"

Here are my values I'm sending back in the Service Module.
"STAGE":{"type":{"t":"A","l":20},"value":"unload"},"JSMCMDX":{"type":{"t":"H","l":512},"value":"SERVICE_UNLOAD"},"JSMSTS":{"type":{"t":"A","l":20},"value":"ERROR"},"JSMMSG":{"type":{"t":"A","l":256},"value":"(0992) - Invalid JSMX handle."}}}}

My is my code

Code: Select all

* OPEN Service and get Handler
Use Builtin(JSMX_OPEN) To_Get(#JSMSTS #JSMMSG #JSMHDLX)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'open'

If Cond('#JSMSTS *NE OK')
#JSMCMDX := 'SERVICE_LOAD SERVICE(SMTPMAILSERVICE)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHDLX #JSMCMDX) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'service'
Endif

If Cond('#JSMSTS *NE OK')
#JSMCMDX := 'SET SERVER(172.20.50.25) TO([email protected]) from([email protected]) from_name(Glynn)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHDLX #JSMCMDX) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'set server'
Endif

If Cond('#JSMSTS *NE OK')
#JSMCMDX := 'SEND SUBJECT(SMTPMAILSERVICE Test)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHDLX #JSMCMDX) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'send'
Endif

If Cond('#JSMSTS *NE OK')
#JSMCMDX := 'SERVICE_UNLOAD'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHDLX #JSMCMDX) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'unload'
Endif

Endroutine


Subroutine Name(Check_Sts) Parms((#JSMSTS *RECEIVED) (#JSMMSG *RECEIVED))
If Cond('#JSMSTS *NE OK')
* Close service and Exit Program
Use Builtin(JSMX_CLOSE) With_Args(#JSMHDLX) To_Get(#JSMSTS #JSMMSG)
Endif
Endroutine

Re: Trying to get SMTPMAILSERVICE working

Posted: Wed May 03, 2017 1:58 am
by jyoung
Don't know if I can help much, but you may try to enable tracing and see if that gives you any more info.

I think all you have to do is use the TRACE(*YES) on the SERVICE_LOAD command. For example this is mine

Code: Select all

* loading SMTPMailService
#SYS_APPLN.TraceMessageText( "Loading SMTPMailService" )
#JSMXCMD := 'SERVICE_LOAD SERVICE(SMTPMAILSERVICE) TRACE(*YES)'
use builtin(JSMX_COMMAND) with_args(#JSMXHDLE #JSMXCMD) to_get(#JSMXSTS #JSMXMSG)
if (#COM_OWNER.CheckStatus( #JSMXSTS #JSMXMSG ))
return
endif
You should be able to find the trace logs in C:\Program Files (x86)\LANSA\Integrator\JSMInstance\trace. I think the folder names are job numbers, but I just look for the folder with a time stamp at the same time I was running the app.

Re: Trying to get SMTPMAILSERVICE working

Posted: Wed May 03, 2017 3:37 pm
by BrendanB
Not sure if this is a typo, but:

Code: Select all

If Cond('#JSMSTS *NE OK')
#JSMCMDX := 'SERVICE_LOAD SERVICE(SMTPMAILSERVICE)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHDLX #JSMCMDX) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'service'
Endif
should be:

Code: Select all

If Cond('#JSMSTS *EQ OK')
#JSMCMDX := 'SERVICE_LOAD SERVICE(SMTPMAILSERVICE)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHDLX #JSMCMDX) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(Check_Sts) With_Parms(#JSMSTS #JSMMSG)
#stage := 'service'
Endif
that is, you want each block to execute ONLY if #JSMSTS = OK, currently the code says to execute each block ONLY IF #JSMSTS is NOT OK

I would think that this is possibly a typo when you were posting.