MimeReplaceStoredMessage
BOOL MimeReplaceStoredMessage(
HMESSAGESTORE hStorage,  
LONG nMessageId,  
HMESSAGE hMessage,  
DWORD dwReserved  
);

The MimeReplaceStoredMessage function replaces the specified message in a message store.

Parameters

hStorage
Handle to the message store.
nMessageId
An integer value which specifies the message number that should be replaced.
hMessage
Handle to the message that will be stored.
dwReserved
A reserved parameter. This value must always be zero.

Remarks

The MimeReplaceStoredMessage function replaces the specified message with a new message. The message number may be a message that has been previously marked for deletion. It is important to note that the change will not be reflected in the physical storage file until it has been closed. If the application needs to replace messages in the message store, it is recommended that the file be opened for exclusive access using the MIME_STORAGE_LOCK option.

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

HMESSAGE hMessage;

// Compose a new message
hMessage = MimeComposeMessage(lpszSender,
                              lpszRecipient,
                              NULL,
                              lpszSubject,
                              lpszMessage,
                              NULL,
                              MIME_CHARSET_DEFAULT,
                              MIME_ENCODING_DEFAULT);

if (hMessage != INVALID_MESSAGE)
{
    HMESSAGESTORE hStorage;
    LONG nLastMessage;
    BOOL bResult;

    // Open the message storage file
    hStorage = MimeOpenMessageStore(lpszFileName, MIME_STORAGE_WRITE);

    if (hStorage == INVALID_MESSAGESTORE)
    {
        // Delete the message and return if we are unable to
        // open the storage file
        MimeDeleteMessage(hMessage);
        return;
    }

    if (MimeGetStoredMessageCount(hStorage, &nLastMessage) < 1)
    {
        // No messages are stored in the file
        MimeCloseMessageStore(hStorage);
        MimeDeleteMessage(hMessage);
        return;
    }

    // Replace the last message in the message store
    bResult = MimeReplaceStoredMessage(hStorage, nLastMessage, hMessage, 0);

    if (bResult == FALSE)
    {
        // We were unable to replace the message
    }

    // Close the message store
    MimeCloseMessageStore(hStorage);

    // Destroy the message that was created
    MimeDeleteMessage(hMessage);
}

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csmsgav6.lib.

See Also

MimeFindStoredMessage, MimeGetStoredMessage, MimeDeleteStoredMessage, MimeStoreMessage


Copyright © 2008 Catalyst Development Corporation. All rights reserved.