MAPI Unicode problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2005
Posts: 1
Reputation: ifulcrum is an unknown quantity at this point 
Solved Threads: 0
ifulcrum ifulcrum is offline Offline
Newbie Poster

MAPI Unicode problem

 
0
  #1
Jul 25th, 2005
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:
  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!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC