CImapClient::OpenMessage Method  
 
INT OpenMessage(
  UINT nMessageId,  
  UINT nMessagePart,  
  DWORD dwOffset,  
  LPDWORD lpdwLength,  
  DWORD dwOptions  
);
INT OpenMessage(
  UINT nMessageId,  
  DWORD dwOptions  
);

The OpenMessage method opens a message or a specific part of a multipart message in the current mailbox. The message data may also be limited a specific byte offset and length, which can be useful for previewing the contents.

Parameters

nMessageId
Number of message to retrieve. This value must be greater than zero. The first message in the mailbox is message number one.
nMessagePart
The message part that will be retrieved. A value of zero specifies that the complete message should be returned. If the message is a multipart MIME message, message parts start with a value of one.
dwOffset
The byte offset into the message. This parameter can be used in conjunction with the lpdwLength parameter to return a specific part of a message. A value of zero specifies the beginning of the message.
lpdwLength
A pointer to an unsigned integer value which should be initialized to the maximum number of bytes to be read, and will contain the size of the message when the method returns. To specify the entire message, from the offset specified by the dwOffset parameter to the end of the message, initialize the lpdwLength parameter to a value of -1. This parameter may be NULL if the message size is not needed.
dwOptions
The low order word of this parameter specifies how the message data will be returned. It may be one of the following values:
Value Description
IMAP_SECTION_DEFAULT All headers and the complete body of the specified message or message part are to be retrieved. The client application is responsible for parsing the header block. If the message is a MIME multipart message and the complete message is returned, the application is responsible for parsing the individual message parts if necessary.
IMAP_SECTION_HEADER All headers for the specified message or message part are to be retrieved. The client application is responsible for parsing the header block.
IMAP_SECTION_MIMEHEADER The MIME headers for the specified message or message are to be retrieved. Only those header fields which are used in MIME messages, such as Content-Type will be returned to the client. This is typically useful when processing the header for a multipart message which contains file attachments. The client application is responsible for parsing the header block.
IMAP_SECTION_BODY The body of the specified message or message part is to be retrieved. For a MIME formatted message, this may include data that is uuencoded or base64 encoded. The application is responsible for decoding this data.
IMAP_SECTION_PREVIEW The message header or body is being previewed and should not be marked as read by the server. This prevents the message from having the IMAP_FLAG_SEEN flag from being automatically set when the message data is retrieved.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The OpenMessageEx method uses the FETCH command to access the specified message on the server. The client can then use the Read method to read the contents of the message.

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
Unicode: Implemented as Unicode and ANSI versions

See Also