GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Jul-2005, 05:38
ifulcrum ifulcrum is offline
New Member
 
Join Date: Jul 2005
Posts: 2
ifulcrum is on a distinguished road

MAPI Unicode problem


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:

CPP / C++ / C 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!!!
Last edited by LuciWiz : 25-Jul-2005 at 05:46. Reason: Please insert your C++ code between [c++] & [/c++] tags
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 13:31
commands out of sync problem (c++ builder) Largowww MS Visual C++ / MFC Forum 0 28-May-2005 04:40
String problem vaha C Programming Language 3 24-May-2005 19:21
inheritance problem ap6118 C++ Forum 8 11-Apr-2005 12:24
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 08:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:30.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.