CMailMessage::Open Method  
 
BOOL Open(
  LPCTSTR lpszFileName,  
  DWORD dwOptions  
);

The Open method opens and reads the specified file.

Parameters

lpszFileName
Pointer to a string which specifies the name of the text file to open. This parameter cannot be NULL.
dwOptions
An integer which specifies options for opening the message file. This parameter is reserved for future use and can be omitted. If specified, it should always be zero in the current implementation.
Value Description
MIME_OPEN_DEFAULT The default mode for opening the message file. Currently, this is the only option which should be specified.

Return Value

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

Remarks

This method opens the specified file, reads the contents into memory and then parses the message. 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 messages stored in a binary format.

If the file path includes environment variables enclosed in percentage (%) symbols, those values will be expanded based on the environment variables defined for the current user using the ExpandEnvironmentStrings function in the Windows API. Note that environment variable names are not case-sensitive.

The maximum size of an individual message is 2 GiB (approximately 2 billion characters). This limitation is implemented as a safety check to prevent opening very large files 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.

Note: This method can only be used to open and parse messages structured according to the MIME (Multipurpose Internet Mail Extensions) standard, such as plain text .eml or .txt files. It cannot open messages stored in proprietary or binary formats used by certain email clients. For example, it does not support Microsoft Outlook message files such as .msg or mailbox files like .pst and .ost, nor does it support formats used by other clients such as Thunderbird's .msf (mail summary files) or the mbox family (.mbx, .mbox) when stored as binary containers. Attempting to open these file types will result in an error. If you need to work with messages exported from Outlook or other proprietary clients, first save or export them in the standard text format before using this method.

If another message was previously opened or created using the same class instance, the internal handle which references the previous message will be closed. If you wish to preserve any changes made to the current message, use the Export method prior to calling this 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