CMailMessage::Import Method  
 
BOOL Import(
  LPCTSTR lpszFileName  
);
BOOL Import(
  LPCTSTR lpszMessage,  
  INT nLength  
);

The Import method imports the message from a file or a string buffer in memory, replacing the current message contents.

Parameters

lpszFileName
A null-terminated string which specifies the name of the file that contains the message to be imported.
lpszMessage
A null-terminated string which contains the message to be imported.
nLength
An integer value which specifies the number of bytes to read from the string buffer. If this argument is -1, then the entire contents of the string up to the terminating null character will be imported.

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

This method replaces the current contents of the message with the contents of the specified file or string buffer. The file must be a text file which uses the standard MIME message structure. It may contain multiple parts, including file attachments and alternative representations of the same message. This function cannot be used to open or parse messages stored in a binary format.

The maximum size of an individual message is 2 GiB (approximately 2 billion characters). This limitation is implemented as a safety check to prevent importing very large files or large blocks of memory which are unlikely to contain a valid MIME formatted message. Most services impose much lower limits on the maximum size of an individual mail message.

If another message was previously opened or created using the same class instance, the previous contents will be cleared prior to importing the new message. If you wish to preserve any changes made to the current message, use the Export method prior to calling this method.

The version of this method which accepts a file name is functionally similar to the Open method.

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

See Also