CImapClient::CreateMessage Method  
 
INT CreateMessage(
  LPCTSTR lpszMailbox,  
  LPBYTE lpMessage,  
  DWORD dwMessageSize,  
  DWORD dwFlags  
);
INT CreateMessage(
  LPCTSTR lpszMailbox,  
  LPCTSTR lpszMessage,  
  DWORD dwFlags  
);

The CreateMessage method creates a message, appending it to the contents of the specified mailbox.

Parameters

lpszMailbox
A null-terminated string which specifies the name of the mailbox that the message will be created in. The mailbox must already exist, and the client must have the appropriate access rights to modify the mailbox.
lpMessage
The buffer which contains the data for the message to be created. An alternate form of the method accepts a pointer to a string.
dwMessageSize
An unsigned integer value which specifies the size of the message data in bytes.
dwFlags
An unsigned integer that specifies one or more message flags. This parameter is constructed by using a bitwise operator with any of the following values:
Value Description
IMAP_FLAG_NONE No value.
IMAP_FLAG_ANSWERED The message has been answered.
IMAP_FLAG_DRAFT The message is not completed and is marked as a draft copy.
IMAP_FLAG_URGENT The message is flagged for urgent or special attention.
IMAP_FLAG_SEEN The message has been read.

Return Value

If the method succeeds, it returns zero. If an error occurs, the method returns IMAP_ERROR. To get extended error information, call GetLastError.

Remarks

If the mailbox does not exist, the method will fail. To create a new mailbox, use the CreateMailbox method. If the message is created in the mailbox that is currently selected, the server may flag it as recent.

This method is typically used by applications to store messages which have already been sent to a user. After a message has been delivered using the SMTP protocol, that same message may be created in a mailbox on the IMAP server so that the user has access to those messages.

If the Unicode version of this method is called and the dwMessageSize parameter is zero, the lpMessage parameter must point to a wide string terminated with a null character. The string will be automatically converted to UTF-8 when the message is created. In all other cases, the lpMessage parameter is treated as a pointer to a byte array which contains the message contents and the dwMessageSize parameter specifies the number of bytes in the array.

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