2

以下一段测试代码在 Windows Mobile 下运行。

它的目标是寻找默认的消息存储,以便我可以获得正确的帐户名称,以便以编程方式编译电子邮件。

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);

PR_DEFAULT_STORE...但是,无法在 Windows Mobile 设备上获取该属性。我猜微软没有准确地实现它。所以,lpProp->ulPropTag永远不会 == PR_DEFAULT_STORE。它始终是 0000。

有没有人在 Windows Mobile 下使用 MAPI 成功获得 PR_DEFAULT_STORE?

还有另一种确定默认消息存储的方法吗?

4

0 回答 0