CImapClient::EnumMessages Method  
 
INT EnumMessages(
  UINT nFirstMessageId,  
  UINT nLastMessageId,  
  DWORD dwMessageFlags,  
  LPIMAPMESSAGE lpMessageList,  
  INT nMaxMessages  
);
INT EnumMessages(
  LPIMAPMESSAGE lpMessageList,  
  INT nMaxMessages  
);

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

Parameters

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.
Value 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 method succeeds, the return value is the number of messages that were enumerated. If no messages match the specified criteria, the method will return a value of zero. If an error is encountered, the method returns IMAP_ERROR. To get extended error information, call GetLastError.

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

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csmapv12.lib

See Also