Trying to get SMTPMAILSERVICE working

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
gstenstrom
Posts: 17
Joined: Thu Feb 16, 2017 8:35 am

Trying to get SMTPMAILSERVICE working

Post by gstenstrom » Wed May 03, 2017 1:29 am

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(glynn.stenstrom@brunbowl.com) from(glynn.stenstrom@brunbowl.com) 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

jyoung
Posts: 653
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Trying to get SMTPMAILSERVICE working

Post by jyoung » Wed May 03, 2017 1:58 am

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.

BrendanB
Posts: 29
Joined: Tue Nov 24, 2015 10:29 am

Re: Trying to get SMTPMAILSERVICE working

Post by BrendanB » Wed May 03, 2017 3:37 pm

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.

Post Reply