OpenStore Method  
 

Open the specified message storage file.

Syntax

object.OpenStore( FileName, [OpenMode] )

Parameters

FileName
A string which specifies the name of the storage file.
OpenMode
An optional integer value which specifies how the storage file will be opened. If this parameter is omitted, the file will be opened for read-only access. One or more of the following values may be specified:
Value Constant Description
0 mimeStoreRead The message store will be opened for read access. The contents of the message store can be accessed, but cannot be modified by the process unless it has also been opened for writing.
1 mimeStoreWrite The message store will be opened for writing. This mode also implies read access and must be specified if the application needs to modify the contents of the message store.
2 mimeStoreCreate The message store will be created if the storage file does not exist. If the file exists, it will be truncated. This mode implies read and write access.
4 mimeStoreLock The message store will be opened so that it may only be accessed and modified by the current process.
&H1000 mimeStoreCompress The contents of the message store are compressed. This option is automatically enabled if a compressed message store is opened for reading or writing.
&H2000 mimeStoreMailbox The message store should use the UNIX mbox format when reading and storing messages. This option is provided for backwards compatibility and is not recommended for general use.

Return Value

A value of zero is returned if the method succeeds. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

The OpenStore method opens a message storage file which contains one or more messages. If the storage file is opened for read access, the application can search the message store and extract messages but it cannot add or delete messages. To add new messages or delete existing messages from the store, it must be opened with write access.

The message store is designed to be a simple, effective way to store multiple messages together in a single file. When the message store is opened, the contents are indexed in memory. Although there is no specific limit to the number of messages that can be stored, there must be sufficient memory available to build an index of each message and its headers. If the application must store and manage a very large number of messages, it is recommended that you use a database rather than a flat-file message store.

Message Store Format
Each message is prefixed by a control sequence of five ASCII 01 characters followed by an ASCII 10 and ASCII 13 character. The messages themselves are stored unmodified in their original text format. The length of each message is calculated based on the location of the control sequence that delimits each message, and explicit message lengths are not stored in the file. This means that it is safe to manually change the message contents, as long as the message delimiters are preserved.

If the message store is compressed, the contents of the storage file are expanded when the file is opened and then re-compressed when the storage file is closed. Using the mimeStoreCompress option reduces the size of the storage file and prevents the contents of the message store from being read using a text file editor. However, enabling compression will increase the amount of memory allocated by the control and can increase the amount of time that it takes to open and close the storage file.

The control also has a backwards compatibility mode where it will recognize storage files that use the UNIX mbox format. While this format is supported for accessing existing files, it is not recommended that you use it when creating new message stores or adding messages to an existing store. There are a number of different variants on the mbox format that have been used by different Mail Transfer Agents (MTAs) on the UNIX platform. For example, the mboxrd variant looks identical to the mboxcl2 variant, and they are programmatically indistinguishable from one another, but they are not compatible. For this reason, the use of the mbox format is strongly discouraged.

See Also

StoreCount Property, StoreFile Property, CloseStore Method, FindMessage Method, ReadStore Method, WriteStore Method