IMAPListMessages

Command groupFlag affectedReversibleExecute on clientPlatform(s)
External commandsYESNONOAll

Syntax

IMAPListMessages
 
(socket,list[,stsproc,responselist,headers])
 
Returns 
status

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded,allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

IMAPListMessages gets the list of messages in the currently selected mailbox.

Before using this command, you must select a mailbox using the IMAPSelectMailbox command

Socket is an Omnis Long Integer field containing a socket opened to an IMAP server using IMAPConnect.

List receives the list of messages in the mailbox. Before calling the command, you must defined the list to have at least nine columns,where the first nine columns are defined as follows:

Column Contains
UID A long integer which receives the IMAP Unique Identifier (UID) of the message. Note that the line number in the list is the IMAP message sequence number, at the point the list was generated. It is safest to use UIDs to identify messages.
Size A long integer which receives the RFC 822 size in bytes of the message.
InternalDate A date-time which receives the Internal Date of the message. This is typically the date and time that the message was placed in the mailbox.
Answered A long integer which is set to kTrue if the message has the \Answered flag, kFalse if not.
Deleted A long integer which is set to kTrue if the message has the \Deleted flag, kFalse if not.
Draft A long integer which is set to kTrue if the message has the \Draft flag, kFalse if not.
Flagged A long integer which is set to kTrue if the message has the \Flagged flag, kFalse if not.
Recent A long integer which is set to kTrue if the message has the \Recent flag, kFalse if not.
Seen A long integer which is set to kTrue if the message has the \Seen flag, kFalse if not.

Columns after these first nine should be defined as character,and receive the headers requested by the Headers parameter.

Stsproc is an optional parameter containing the name of an Omnis method that this command calls with status messages. This command calls the method with no parameters, and the status information in the variable #S1. The status information logs protocol messages exchanged on the connection to the server.

Responselist is a parameter into which this command places response lines received from the IMAP server. Before calling this command, define the responselist to have a single Character column. When the command returns successfully, the response list contains the untagged and tagged responses received from the IMAP server as a result of executing this command. These sometimes include unsolicited information, for example, an update on the current number of messages in the selected mailbox. Each line in the response list is a response line received from the server. See RFC 3501 for more details, if you need to handle this sort of information. You can only omit the Responselist parameter if it would be the last parameter you are passing to the command.

Headers is an optional parameter that allows you to request named RFC822 message headers to be included in the list of messages. A space-separated list of header names e.g. "Subject From". The command stores the headers in consecutive columns of the List, starting at column 10, in the order of the header names.

This command returns an integer, which is less than zero if an error occurred. Possible error codes are listed in the Web Command Error Codes Appendix.

Example

# List all messages in the currently selected mailbox

Do
 
iMessageList
.
$define
(
iUID
,
iSize
,
iInternalDate
,
iAnswered
,
iDeleted
,
iDraft
,
iFlagged
,
iRecent
,
iSeen
)

IMAPListMessages
 
(
iIMAPSocket
,
iMessageList
)
 
Returns 
lStatus

If
 
lStatus
<0

  
# Command failed

End If