locked
Mapi problem w Unicode RRS feed

  • Question

  • Hello,

    i have problem with Mapi and unicode.
    I'm workking under win XP, outlook 2000, visual studio c++ 6.0 and extended MAPI.
    I'm trying get contacts (and information about contacts) from outlook.
    Everything working when i'm not using Unicode. I get contacts, properties and so on. Problem

    occurs, when i'm start doing the same in Unicode. Funny is, that functions did not return

    error, everything looks fine, but the memory field with information is empty!!! Why?

    Here is code:
    #include "stdafx.h"
    #include <afxwin.h>
    #include <mapi.h>
    #include <mapix.h>
    #include <mapiutil.h>

    int main(int argc, char* argv[])
    {
    HRESULT hr = S_OK;

    ULONG cbeid = 0L;
    LPENTRYID lpeid = NULL;
    LPSRowSet pRow;
    ULONG ulObjType;
    LPMAPITABLE lpContentsTable = NULL;
    LPABCONT lpGAL = NULL;
    LPADRBOOK m_pAddrBook = NULL;
    LPMAPISESSION pSession;


    SizedSPropTagArray ( 13, sptCols ) = { 13,
    PR_ENTRYID,
    PR_DISPLAY_NAME,
    PR_EMAIL_ADDRESS,
    PR_ACCOUNT,
    PR_ASSISTANT,
    PR_ASSISTANT_TELEPHONE_NUMBER,
    PR_BUSINESS_FAX_NUMBER,
    PR_BUSINESS_TELEPHONE_NUMBER,
    PR_BUSINESS2_TELEPHONE_NUMBER,
    PR_CALLBACK_TELEPHONE_NUMBER,
    PR_CAR_TELEPHONE_NUMBER,
    PR_COMPANY_NAME,
    PR_COUNTRY
    };

    hr = MAPIInitialize (NULL);

    hr = MAPILogonEx (NULL, NULL, NULL, MAPI_EXTENDED | MAPI_ALLOW_OTHERS | MAPI_NEW_SESSION |

    MAPI_LOGON_UI | MAPI_EXPLICIT_PROFILE | MAPI_UNICODE,&pSession);

    hr = pSession->OpenAddressBook(NULL,NULL,NULL,&m_pAddrBook);

    hr = m_pAddrBook->GetPAB(&cbeid,&lpeid);

    hr = m_pAddrBook->OpenEntry((ULONG) cbeid,(LPENTRYID)

    lpeid,NULL,MAPI_BEST_ACCESS,&ulObjType,(LPUNKNOWN *)&lpGAL);

    hr = lpGAL->GetContentsTable(0L, &lpContentsTable);

    hr = HrQueryAllRows (lpContentsTable,(SPropTagArray*) &sptCols, NULL, NULL, 0,&pRow);

    for(int x=0; x < (int) pRow->cRows ;x++)
    {

    wprintf(L"%ls\n", pRow->aRow[x].lpProps[1].Value.lpszW);
    wprintf(L"%ls\n", pRow->aRow[x].lpProps[2].Value.lpszW);
    wprintf(L"%ls\n", pRow->aRow[x].lpProps[3].Value.lpszW);
    wprintf(L"%ls\n", pRow->aRow[x].lpProps[4].Value.lpszW);
    wprintf(L"%ls\n", pRow->aRow[x].lpProps[5].Value.lpszW);
    }

    if ( NULL != lpGAL)
    {
    lpGAL -> Release ( );
    lpGAL = NULL;
    }
    if ( lpContentsTable )
    {
    lpContentsTable -> Release ( );
    lpContentsTable = NULL;
    }

    m_pAddrBook->Release();
    pSession->Release();

    return true;
    }

    Thanks a lot!!!
    Tuesday, July 26, 2005 9:20 AM

Answers

  • You might want to check out the psdk discussion groups as they are more apt to have the answers you seek.

    microsoft.public.platformsdk.mapi
    Thursday, August 18, 2005 7:44 PM