ImapEnumMessages Function  
 
INT WINAPI ImapEnumMessages(
  HCLIENT hClient,  
  UINT nFirstMessageId,  
  UINT nLastMessageId,  
  DWORD dwMessageFlags,  
  DWORD dwReserved,  
  LPIMAPMESSAGE lpMessageList,  
  INT nMaxMessages  
);

The ImapEnumMessages function enumerates the messages in the current mailbox, populating an array of IMAPMESSAGE structures which contain information about each message.

Parameters

hClient
Handle to the client session.
nFirstMessageId
An unsigned integer value which specifies the first message to enumerate. This value must be greater than zero and specify a valid message identifier. The first message in the mailbox has a value of one.
nLastMessageId
An unsigned integer value which specifies the last message to enumerate. This value must be greater than or equal to the value of the nFirstMessageId parameter. A special value of 0xFFFFFFFF can be used to specify the last message in the mailbox.
dwMessageFlags
This parameter is used to determine which messages are enumerated. If the value is zero, then all applicable messages will be enumerated. If the value is non-zero, only those messages which have at least one of the specified flags will be returned. More than one flag can be specified by using a bitwise operator. Valid message flags are:
Constant Description
IMAP_FLAG_ANSWERED Return only those messages which have been answered.
IMAP_FLAG_DELETED Return only those messages which have been marked for deletion.
IMAP_FLAG_DRAFT Return only those messages which have been marked as draft copies.
IMAP_FLAG_URGENT Return only those messages which have been flagged for urgent or special attention.
IMAP_FLAG_RECENT Return only those messages which have been recently added to the mailbox.
IMAP_FLAG_SEEN Return only those messages which have been read.
dwReserved
A reserved parameter. This value should always be set to zero.
lpMessageList
A pointer to an array of IMAPMESSAGE structures which will contain information about each of the messages returned by the server. This parameter cannot be NULL.
nMaxMessages
An integer value which specifies the maximum size of the IMAPMESSAGE array that was passed to the function. This value must be at least one.

Return Value

If the function succeeds, the return value is the number of messages that were enumerated. If no messages match the specified criteria, the function will return a value of zero. If an error is encountered, the function returns IMAP_ERROR. To get extended error information, call ImapGetLastError.

Remarks

If the message UID is being stored locally by the client to identify the message over multiple sessions, it must also store the mailbox UID. Only the combination of the mailbox name, mailbox UID and message UID can be used to uniquely identify a given message on the server. Although IMAP server implementations are encouraged to maintain persistent message UIDs, they are not required to do so and those values may change if the mailbox UID changes.

Requirements

Client: Requires Windows 7, Windows Vista or Windows XP.
Server: Requires Windows Server 2008 or Windows Server 2003.
Header: Include cstools7.h.
Library: Use csmapav7.lib.

See Also

ImapGetMessage, ImapGetMessageCount, ImapGetMessageFlags, ImapGetMessageHeaders, ImapGetMessageSize, ImapGetMessageUid