Command IMAP_GetMessage

4D Internet Commands

IMAP_GetMessage

version 6.8.1


IMAP_GetMessage (imap_ID; msgNum; offset; length; msgPart; msgText{; updateSeen}) Integer

ParameterTypeDescription
imap_IDLongintReference to an IMAP login
msgNumLongintMessage number
offsetLongintOffset of character at which to begin retrieval
lengthLongintHow many characters to return
msgPartInteger0 = Entire message, 1 = Only header, 2= Only Body
msgTextTextMessage Text
updateSeenInteger0 = Update \Seen Flag; 1 = Do not update

Function result Integer Error code

Description

The IMAP_GetMessage command returns the complete text of the message identified by msgNum within the current mailbox referenced by IMAP_SetCurrentMB. Unless otherwise specified by the IMAP_SetPrefs command, any linefeed characters within the message will be removed.

The IMAP_GetMessage command returns either the entire block of the message, including header information, or with header only or body only, depending on the msgPart parameter.

imap_ID is a long integer reference to an open connection created with IMAP_Login.

msgNum is a long integer value indicating which message in the mailbox to retrieve. This number represents the position of a message within the current list of messages. You cannot rely on msgNum remaining the same for a specific e-mail item from session to session.

offset is a long integer value indicating the number of characters from the beginning of the specified msgPart to begin reading. In most circumstances a zero should be passed to this parameter.

length is a long integer value representing the number of characters beyond the offset position to retrieve. Since the maximum length of a 4D text variable is limited to 32,000 characters, the length parameter should be set to any number below 32,000. Messages whose msgPart size is greater than 32K must be saved to the disk via the IMAP_Download command.

msgPart indicates the message part to retrieve. Values 0, 1 or 2 can be passed:

• 0 = Entire message,

• 1 = Only header,

• 2 = Only body (means first Text/ plain encountered).

Retrieving entire message or only header retrieves raw text without decoding. On the other hand, when retrieving only body, the text will be decoded and converted automatically if needed (see POP3_Charset for more information concerning decoding and conversion rules).

updateSeen is an integer value that indicates if the flag \Seen has to be added to the message flags whether implicitly or not. This parameter is optional and the default value is used if this parameter is not passed.

• 0 = Add \Seen Flag (default value);

• 1= Do not add \Seen Flag;

msgText is a text variable that will receive the retrieved text.

See Also

IMAP_Download, IMAP_Login, IMAP_SetCurrentMB, IMAP_SetPrefs.