IMAPISession::GetMsgStoresTable (Compact 7)
3/12/2014
The GetMsgStoresTable method provides access to the message store table, which contains information about all of the message stores in the session profile.
Syntax
HRESULT GetMsgStoresTable (
ULONG ulFlags,
LPMAPITABLE FAR * lppTable
);
Parameters
- ulFlags
[in] Ignored.
- lppTable
[out] Reference to the message store table, implemented on IMAPITable.
Return Value
This method returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:
- S_OK
Indicates success.
Remarks
GetMsgStoresTable retrieves a pointer to the message store table, a table maintained by MAPI that contains information about each open message store in the profile.
The following IMAPITable methods are supported for message store tables in Windows Embedded Compact Messaging:
Because MAPI updates the message store table during the session whenever changes occur, call the IMAPISession::Advise method to register to be notified of these changes. Possible changes include the addition of new message stores, removal of existing stores, and changes to the default store.
Code Example
The following code example demonstrates how to use GetMsgStoresTable.
Note
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int CmdShow)
{
HRESULT hr;
IMAPISession * pSession = NULL;
IMAPITable * pTable = NULL;
IMsgStore * pStore = NULL;
IMessage * pmsg = NULL;
SRowSet * psrs = NULL;
SPropValue * rgprops = NULL;
SPropValue * rgpropsMsg = NULL;
LPMAPIFOLDER pfldrDrafts = NULL;
ULONG rgTags[] = { 1, PR_CE_IPM_DRAFTS_ENTRYID };
ULONG cValues = 0;
// Logon to the store.
hr = MAPILogonEx(NULL, NULL, NULL, NULL, &pSession);
// Get the message stores table.
while (SUCCEEDED(pTable->QueryRows(1, 0, &psrs)))
{
// Check the number of rows returned. Since the above call only asks for one row, then anything else means we are at the end of the table.
if (1 != psrs->cRows)
break;
// Make sure to get all the properties that you need.
if ((1 > psrs->aRow[0].cValues)||(PR_ENTRYID != psrs->aRow[0].lpProps[0].ulPropTag))
{
MessageBox(NULL, L"Store missing PR_ENTRYID!", L"Error", MB_OK);
hr = E_FAIL;
break;
}
// Open this message store.
hr = pSession->OpenMsgStore(NULL, psrs->aRow[0].lpProps[0].Value.bin.cb, (ENTRYID *)psrs->aRow[0].lpProps[0].Value.bin.lpb, NULL, 0, &pStore);
// Get the Drafts folder. For a message to be sent by MAPI, it must be created in the Drafts folder.
hr = pStore->GetProps((SPropTagArray *)rgTags, MAPI_UNICODE, &cValues, &rgprops);
hr = pStore->OpenEntry(rgprops[0].Value.bin.cb, (LPENTRYID)rgprops[0].Value.bin.lpb, NULL, MAPI_MODIFY, NULL, reinterpret_cast <IUnknown **>(&pfldrDrafts));
// Create a message.
hr = pfldrDrafts->CreateMessage(NULL, 0, &pmsg);
// Send the message.
hr = pmsg->SubmitMessage(0);
// Free resources.
MAPIFreeBuffer(rgprops);
MAPIFreeBuffer(rgpropsMsg);
FreeProws(psrs);
rgprops = NULL;
rgpropsMsg = NULL;
psrs = NULL;
RELEASE_OBJ(pmsg);
RELEASE_OBJ(pfldrDrafts);
RELEASE_OBJ(pStore);
}
FuncExit:
//Clean up
MAPIFreeBuffer(rgprops);
MAPIFreeBuffer(rgpropsMsg);
FreeProws(psrs);
RELEASE_OBJ(pmsg);
RELEASE_OBJ(pfldrDrafts);
RELEASE_OBJ(pStore);
RELEASE_OBJ(pTable);
RELEASE_OBJ(pSession);
return 0;
}
Requirements
Header |
mapix.h |
Library |
cemapi.lib |