From: sedwo on
I want to get the default user account name for programmatically
compiling an email.

The following piece of *test code* runs under Windows Mobile. It's
objective is to seek out the default message store...


IMAPISession *mapiSession;
HRESULT hr = S_OK;

MAPIInitialize (NULL);
IMAPITable *msgTable;

SRowSet *pRows;
IMsgStore *msgStore;

if (MAPILogonEx(0,NULL,NULL,0,&mapiSession) != S_OK)
{
// MessageBox(g_hWnd,_T("Failed to logon"),_T("Error"),0);
}
else
{
SizedSPropTagArray(3, PropTagArr) = {3,{PR_DISPLAY_NAME,
PR_ENTRYID,
PR_DEFAULT_STORE}};

hr = mapiSession->GetMsgStoresTable(MAPI_UNICODE,&msgTable);

hr = msgTable->SetColumns((LPSPropTagArray)&PropTagArr, 0);

if (!hr)
{
do
{
hr = msgTable->QueryRows(1,0,&pRows);

LPSPropValue lpProp;
lpProp = &pRows->aRow[0].lpProps[0];

// if(_tcscmp( lpProp->Value.LPSZ, _T("SMS") ) == 0 )
// break;

lpProp = &pRows->aRow[0].lpProps[0];
if (lpProp->ulPropTag == PR_DEFAULT_STORE)
break;

lpProp = &pRows->aRow[0].lpProps[1];
if (lpProp->ulPropTag == PR_DEFAULT_STORE)
break;

lpProp = &pRows->aRow[0].lpProps[2];
if (lpProp->ulPropTag == PR_DEFAULT_STORE)
break;

FreeProws(pRows);
pRows = NULL;

}while (!hr);

hr = mapiSession->OpenMsgStore (0,
pRows->aRow[0].lpProps[1].Value.bin.cb,
(ENTRYID*)pRows->aRow[0].lpProps
[1].Value.bin.lpb,
NULL,
MDB_NO_DIALOG | MAPI_BEST_ACCESS,
&msgStore);


.... BUT, fails to get the PR_DEFAULT_STORE property on a Windows
Mobile device. I'm guessing Microsoft didn't implement it accurately.
And so, lpProp->ulPropTag will never == PR_DEFAULT_STORE. It's always
0000.

Which leads me to my question, is there another way of the determing
the default message store?

Thank you.