944,001 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4538
  • C++ RSS
Jul 25th, 2005
0

MAPI Unicode problem

Expand Post »
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:
C++ Syntax (Toggle Plain Text)
  1. #include "stdafx.h"
  2. #include <afxwin.h>
  3. #include <mapi.h>
  4. #include <mapix.h>
  5. #include <mapiutil.h>
  6.  
  7. int main(int argc, char* argv[])
  8. {
  9. HRESULT hr = S_OK;
  10.  
  11. ULONG cbeid = 0L;
  12. LPENTRYID lpeid = NULL;
  13. LPSRowSet pRow;
  14. ULONG ulObjType;
  15. LPMAPITABLE lpContentsTable = NULL;
  16. LPABCONT lpGAL = NULL;
  17. LPADRBOOK m_pAddrBook = NULL;
  18. LPMAPISESSION pSession;
  19.  
  20.  
  21. SizedSPropTagArray ( 13, sptCols ) = { 13,
  22. PR_ENTRYID,
  23. PR_DISPLAY_NAME,
  24. PR_EMAIL_ADDRESS,
  25. PR_ACCOUNT,
  26. PR_ASSISTANT,
  27. PR_ASSISTANT_TELEPHONE_NUMBER,
  28. PR_BUSINESS_FAX_NUMBER,
  29. PR_BUSINESS_TELEPHONE_NUMBER,
  30. PR_BUSINESS2_TELEPHONE_NUMBER,
  31. PR_CALLBACK_TELEPHONE_NUMBER,
  32. PR_CAR_TELEPHONE_NUMBER,
  33. PR_COMPANY_NAME,
  34. PR_COUNTRY
  35. };
  36.  
  37. hr = MAPIInitialize (NULL);
  38.  
  39. hr = MAPILogonEx (NULL, NULL, NULL, MAPI_EXTENDED | MAPI_ALLOW_OTHERS | MAPI_NEW_SESSION |
  40.  
  41. MAPI_LOGON_UI | MAPI_EXPLICIT_PROFILE | MAPI_UNICODE,&pSession);
  42.  
  43. hr = pSession->OpenAddressBook(NULL,NULL,NULL,&m_pAddrBook);
  44.  
  45. hr = m_pAddrBook->GetPAB(&cbeid,&lpeid);
  46.  
  47. hr = m_pAddrBook->OpenEntry((ULONG) cbeid,(LPENTRYID)
  48.  
  49. lpeid,NULL,MAPI_BEST_ACCESS,&ulObjType,(LPUNKNOWN *)&lpGAL);
  50.  
  51. hr = lpGAL->GetContentsTable(0L, &lpContentsTable);
  52.  
  53. hr = HrQueryAllRows (lpContentsTable,(SPropTagArray*) &sptCols, NULL, NULL, 0,&pRow);
  54.  
  55. for(int x=0; x < (int) pRow->cRows ;x++)
  56. {
  57.  
  58. wprintf(L"%ls\n", pRow->aRow[x].lpProps[1].Value.lpszW);
  59. wprintf(L"%ls\n", pRow->aRow[x].lpProps[2].Value.lpszW);
  60. wprintf(L"%ls\n", pRow->aRow[x].lpProps[3].Value.lpszW);
  61. wprintf(L"%ls\n", pRow->aRow[x].lpProps[4].Value.lpszW);
  62. wprintf(L"%ls\n", pRow->aRow[x].lpProps[5].Value.lpszW);
  63. }
  64.  
  65. if ( NULL != lpGAL)
  66. {
  67. lpGAL -> Release ( );
  68. lpGAL = NULL;
  69. }
  70. if ( lpContentsTable )
  71. {
  72. lpContentsTable -> Release ( );
  73. lpContentsTable = NULL;
  74. }
  75.  
  76. m_pAddrBook->Release();
  77. pSession->Release();
  78.  
  79. return true;
  80. }
<< moderator edit: added [code][/code] tags >>

Thanks a lot!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ifulcrum is offline Offline
1 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Error compiling complex.cpp
Next Thread in C++ Forum Timeline: Linker Error>Undefined reference error to xyz





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC