MimeImportMessageEx Function  
 
BOOL WINAPI MimeImportMessageEx(
  HMESSAGE hMessage,  
  DWORD dwImportMode,  
  DWORD dwImportOptions,  
  LPVOID lpvMessage,  
  DWORD dwMessageSize  
);

The MimeImportMessageEx function imports the contents of a message from a file, string or memory handle.

Parameters

hMessage
Handle to the message.
dwImportMode
An unsigned long integer which specifies how the message contents will be imported. It may be one of the following values:
Constant Description
MIME_IMPORT_DEFAULT The default import mode. If the lpvMessage parameter is NULL, then the contents of the message will be imported from the system clipboard. Otherwise, the lpvMessage parameter is a pointer to a null-terminated string which specifies the name of a file to import the message from. The dwMessageSize parameter is ignored.
MIME_IMPORT_FILE The lpvMessage parameter is a pointer to a null-terminated string which specifies the name of a file to import the message from. If the file does not exist, or is not a regular text file, an error will occur. The dwMessageSize parameter is ignored.
MIME_IMPORT_CLIPBOARD The contents of the message is imported from the system clipboard. The lpvMessage parameter is ignored. The dwMessageSize parameter is ignored.
MIME_IMPORT_MEMORY The contents of the message is imported from a local buffer. The lpvMessage parameter must point to a byte array which contains the message to be imported. The dwMessageSize parameter specifies the number of bytes to copy from the buffer. If this value is zero, it is assumed that the end of the message data in the buffer is terminated with a null byte and the length is calculated automatically.
MIME_IMPORT_HGLOBAL The contents of the message is imported from a global memory buffer. The lpvMessage parameter must be a global memory handle which contains the message. The dwMessageSize parameter specifies the number of bytes to copy from the buffer. If this value is zero, it is assumed that the end of the message data in the buffer is terminated with a null byte and the length is calculated automatically.
dwImportOptions
An unsigned long integer which specifies how the message will be imported:
Constant Description
MIME_OPTION_DEFAULT The default import options. Currently this is the only valid value for this parameter and applications should always specify this constant.
lpvMessage
A pointer to a null-terminated string, a byte buffer or a global memory handle. The dwImportMode parameter determines how this pointer is used by the function.
dwMessageSize
An unsigned long integer value which specifies the size of the message to import. This parameter is only used when importing a message from a memory buffer. The message size is determined automatically when the message is imported from a file or the system clipboard.

Return Value

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

Example

The following example imports a message using an HGLOBAL handle that references a block of memory that contains an e-mail message:

bResult = MimeImportMessageEx(hMessage,
                              MIME_IMPORT_HGLOBAL,
                              MIME_OPTION_DEFAULT,
                              (LPVOID)hgblMessage,
                              0);

if (bResult)
{
    // The message has been sucessfully imported
}

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

See Also

MimeCreateMessage, MimeExportMessage, MimeExportMessageEx, MimeImportMessage