READ

The READ command places the specified message content into a working list. The working list definition must be appropriate for the expected content. For example, if you nominate to read text content a single field is required in your working list. If you are reading anything other than text (i.e. content which includes a separator value) the working list must be defined so it can handle the maximum number of columns in the content.

The ENCODING keyword and CONTENT keyword control the content handling requirements.

 

                                                           Required

 

 READ ---------- OBJECT --------- none --------------------------->

                                  *TEXT

                                  *ATTACHMENT

 

                                                           Optional

 

             >-- CONTENT -------- *TEXT -------------------------->

                                  *CSV

                                  *TSV

                                  *SV

 

             >-- SEPARATOR ------ value -------------------------->

                                  *COMMA

                                  *SEMICOLON

                                  *TAB

                                  *TILDE

 

             >-- ENTRY ---------- 1 ------------------------------>

                                  value

 

             >-- SELECT --------- value -------------------------->

 

             >-- ENCODING ------ *DEFAULT ------------------------>

                                 value

 

             >-- SVROW ---------- value -------------------------->

 

             >-- SVROWLIMIT ----- value -------------------------->

                                  *NONE

                                  *LIST

                                  *AVAILABLE

 

             >-- SVMODE --------- *NONE -------------------------->

                                  *IGNORE

                                  *USE 

 

             >-- SVHEAD --------- value -------------------------->

 

             >-- NUMBERFORMAT --- *NONE --------------------------|

                                  *DEFAULT

                                  *CLIENT 

                                  *USERAGENT

                                  value

 

Keywords

OBJECT

This keyword specifies what part of the current message is to be read.

A value of *TEXT indicates the body text of the message is to be read into a working list. If the message content-type does not start with text/ or multipart/ the command will return NOTEXT in the status field.

Use a value of *ATTACHMENT to nominated a specific attachment to be read into a working list. Use this value in combination with the ENTRY or SELECT keywords to identify the attachment to be saved. If neither ENTRY nor SELECT is specified the first attachment is saved. If there are no attachments associated with the current message the command status is returned as NOATTACHMENT.

Refer to RDML / RDMLX Reserved Keywords for details on how to define the working list on the command. 

CONTENT

By default the email content is processed as text.

If the attachment is plain text, use CONTENT(*TEXT) to read the text into the working list.

Alternately the content can be processed as a Comma separated variables (*CSV), Tab separated variables (*TSV) or separated by a variable (*SV) as specified in the separator keyword. If processing content that includes a separator variable refer to the SEPARATOR, SVHEAD,  SVMODE, NUMBERFORMAT, TRIM and TRUNCATE keywords for additional processing options.

The working list used to store the body text or attachment content must be defined with an appropriate number of columns to store the data. Refer to RDML / RDMLX Reserved Keywords for details on how to define the working list on the command.

SEPARATOR

This keyword is used by separated value services to identify the content separator.

If the SEPARATOR keyword is present and no CONTENT keyword is provided then CONTENT(*SV) is assumed.

Refer to SEPARATOR for more information.

ENTRY

Specify the file number of the attachment to be saved. The default value is 1. The number assigned to each attachment is determined by the order the attachments were added to the email by the sender.

SELECT

Select an attachment file to be saved based on the attached file name.

ENCODING

Specify what encoding must be applied to a bytes content to convert it to a Unicode string. The default value for the ENCODING keyword is *DEFAULT.

Refer to ENCODING for more information.

SVROW

The optional keyword SVROW is used to specify the starting row when reading records.

Refer to SVROW for more information.

SVROWLIMIT

The optional keyword SVROWLIMIT is used to specify the number of rows to be read.

Refer to SVROWLIMIT for more information.

SVMODE

This keyword is used by content handlers and services that process separated value data to define how to handle the inbound separated value data.

Refer to  SVMODE for more information.

SVHEAD

The optional keyword is used to describe the field layout of the separated value data.

Refer to SVHEAD for more information.

NUMBERFORMAT

This optional keyword handles numeric strings where the decimal separator is not the decimal point character ".".

Refer to NUMBERFORMAT for more information.

Examples

RDML

Using the TRUNCATE keyword ensure body content is added to the working list even if the line length exceeds the length of the field in the working list.

 

DEF_LIST NAME(#BODYLST) FIELDS(#STD_TEXT) TYPE(*WORKING)

 

CHANGE FIELD(#JSMCMD) TO('READ OBJECT(*TEXT) SERVICE_LIST(STD_TEXT) TRUNCATE(*BOTH)')

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

 

 

RDMLX

Attachment files can be processed according to their content and the users knowledge of the content. For example when an email has an attachment file message01.txt with content like:

 

     first, second, third, fourth

     1, 2, 3, 4

     uno, dos, tres , quatro

     un , deux , trios ,

 

Read the content of this attachment as text (with each line of content place into a single field in a working list)

 

def_list name(#attachlst) fields(#fielda) type(*working)

 

use builtin(jsmx_command) with_args(#jsmhandle 'read object(*attachment) content(*text) select(message01.txt)') to_get(#jsmsts #jsmmsg #attachlst)

 

or

 

Read the attachment as a comma separated variables file (where the working list would be required to have four columns).

 

def_list name(#attachlst) fields(#fielda #fieldb #fieldc #fieldd) type(*working)

 

use builtin(jsmx_command) with_args(#jsmhandle 'read object(*attachment) content(*csv) select(message01.txt)') to_get(#jsmsts #jsmmsg #attachlst)