|
LONG WINAPI MimeFindStoredMessage( |
|
HMESSAGESTORE hStorage, |
|
|
LONG nMessageId, |
|
|
LPCTSTR lpszHeaderName, |
|
|
LPCTSTR lpszHeaderValue, |
|
|
DWORD dwOptions |
|
); |
The MimeFindStoredMessage function searches for a message
in the specified message store.
Parameters
- hStorage
- Handle to the message store.
- nMessageId
- An integer value which specifies the message number that should
be used when starting the search. The first message in the message
store has a value of one.
- lpszHeaderName
- The string which specifies the name of the header
field that should be searched. The header field name is not case
sensitive. This parameter cannot be NULL.
- lpszHeaderValue
- The string which specifies the header value that
should be searched for. The search options can be used to specify
if the search is case-sensitive, and whether the search should
return partial matches to the string. This parameter cannot be
NULL.
- dwOptions
- A value which specifies one or more options. This parameter is
constructed by using a bitwise operator with any of the following
values:
Value |
Description |
MIME_SEARCH_DEFAULT |
Perform a complete match against the specified header
value. The comparison is not case-sensitive. |
MIME_SEARCH_CASE_SENSITIVE |
The header field value comparison will be case-sensitive.
Note that this does not affect header field names. Matches for
header names are always case-insensitive. |
MIME_SEARCH_PARTIAL_MATCH |
Perform a partial match against the specified header value.
It recommended that this option be used when searching for
matches to email addresses. |
MIME_SEARCH_DECODE_HEADERS |
Decode any encoded message headers before comparing them to
the specified value. This option can increase the amount of
time required to search the message store and should only be
used when necessary. |
Return Value
If the function succeeds, the return value is the number for the
message which matches the search criteria. If the function fails, the
return value is MIME_ERROR. To get extended error information, call
MimeGetLastError.
Remarks
The MimeFindStoredMessage function is used to search the
message store for a message which matches a specific header field
value. For example, it can be used to find every message which is
addressed to a specific recipient or has a subject which matches a
particular string value.
Example
HMESSAGE hMessage = INVALID_MESSAGE;
LPCTSTR lpszHeader = _T("From");
LPCTSTR lpszAddress = _T("jsmith@example.com");
LONG nMessageId = 1;
// Begin searching for messages from the specified sender
while (nMessageId != MIME_ERROR)
{
nMessageId = MimeFindStoredMessage(hStorage,
nMessageId,
lpszHeader,
lpszAddress,
MIME_SEARCH_PARTIAL_MATCH);
if (nMessageId != MIME_ERROR)
{
hMessage = MimeGetStoredMessage(hStorage, nMessageId, 0);
if (hMessage != INVALID_MESSAGE)
{
// Store the message in a file
TCHAR szFileName[MAX_PATH];
BOOL bExported;
wsprintf(szFileName, _T("msg%05ld.tmp"), nMessageId);
bExported = MimeExportMessage(hMessage, szFileName);
}
nMessageId++;
}
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csmsgv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
MimeGetStoredMessage,
MimeGetStoredMessageCount,
MimeDeleteStoredMessage
|
|