GET

LANSA Integrator

GET

The GET command retrieves email details from the mail server. The GET command is usually used repetitively to get all the messages and appropriate information pertaining to the messages.

 

                                                      Conditional

 

 GET -------- OBJECT ------------- none ------------------------|

                                   *MESSAGECOUNT

                                   *FIRSTMESSAGE

                                   *NEXTMESSAGE

                                   *TOADDRESS

                                   *CCADDRESS

                                   *FROMADDRESS

                                   *SUBJECT

                                   *SENTDATE

                                   *ATTACHMENTS

                                   *UID

                                   *HEADER

 

Keywords

OBJECT

This keyword must be specified on the GET command with one of the predetermined values.

A value of *MESSAGECOUNT will return the number of messages in the folder in the JSM command message parameter.

A value of *FIRSTMESSAGE sets the current message to the first message in the folder. If no message is available the command status field is set to NOMAIL.

Specifying a value of *NEXTMESSAGE will get the next mail message in the folder and set this as the current message. If there are no more messages the command status field is set to NOMAIL. If a message is found the command status is returned as OK. The *NEXTMESSAGE processing is usually followed by another GET command to retrieve the details of the message e.g. the subject, from address or attachments, or the SAVE command to get the actual body of the message.

A value of *TOADDRESS will return the email address of the email recipient(s) into the JSM command message parameter or, if a list is provided, into the working list.

A value of *CCADDRESS will return the email address of the email recipient(s) into the JSM command message parameter or, if a list is provided, into the working list.

A value of *FROMADDRESS will return the email address of the email sender into the JSM command message parameter or, if a list is provided, into the working list.

A value of *FROMADDRESS will return the email address of the email sender into the JSM command message parameter or, if a list is provided, into the working list.

A value of *SUBJECT will return the subject of the current message in the JSM command message parameter.

A value of *SENTDATE will return the date the email was sent in the JSM command message parameter.

Specifying *ATTACHMENTS will return a working list with an entry detailing the file name of each attachment on the current email.

A value of *UID will return the unique identifier of the current message.

Specifying *HEADER and using the keyword FIELD to specify which MIME header field to be returned.

Examples

The following examples use the GET command to retrieve email details from the mail server.

RDML

 

* loop through all the messages

BEGIN_LOOP

 

* Get message

USE BUILTIN(JSM_COMMAND) WITH_ARGS('GET OBJECT(*NEXTMESSAGE)') TO_GET(#JSMSTS #JSMMSG)

IF COND('#JSMSTS *EQ NOMAIL')

LEAVE

ENDIF

 

* Get subject

USE BUILTIN(JSM_COMMAND) WITH_ARGS('GET OBJECT(*SUBJECT)') TO_GET(#JSMSTS #JSMMSG)

CHANGE FIELD(#SUBJECT) TO(#JSMMSG)

 

* Get from addresses

USE BUILTIN(JSM_COMMAND) WITH_ARGS('GET OBJECT(*FROMADDRESS) SERVICE_LIST(ADDRESS)') TO_GET(#JSMSTS #JSMMSG)

CHANGE FIELD(#FROM) TO(#JSMMSG)

 

* <<do something with email details>>

 

END_LOOP

 

RDMLX

 

* loop through all the messages

begin_loop

 

* Get the next message

use builtin(jsmx_command) with_args(#jsmhandle 'get object(*nextmessage)') to_get(#jsmsts #jsmmsg)

if (#jsmsts = NOMAIL)

leave

endif

 

* Get subject

use builtin(jsmx_command) with_args(#jsmhandle 'get object(*subject)') to_get(#jsmsts #jsmmsg)

#jsmsubject := #jsmmsg

 

* Get from address

use builtin(jsmx_command) with_args(#jsmhandle 'get object(*fromaddress)') to_get(#jsmsts #jsmmsg)

#jsmfrom := #jsmmsg

 

* <<do something with email details>>

 

end_loop