none
MAPIAdminProfiles - query PR_DISPLAY_NAME column fails with unicode build RRS feed

  • Question

  • My code is querying rows from the MAPI profile table.  Before the query, it calls SetColumns as follows:

          SizedSPropTagArray (2, profileCols) = { 2, {PR_DISPLAY_NAME, PR_DEFAULT_PROFILE} };
          hr = profileTable->SetColumns ((SPropTagArray*)&profileCols, 0);
          if (hr != S_OK) 
             ...

    However, this results in an invalid string comming back for PR_DISPLAY_NAME.  It gets the tag 0x3001000A -- PT_ERROR.

    I eventually discovered that changing the SPropTagArray to contain PR_DISPLAY_NAME_A, instead, works.  I'm glad it works, but what I'm doing doesn't seem right.  Should I be doing something else? 

    Please note, this is a unicode build using mapi from Outlook 2003 on XP.  I'd like the code to work with that version of outlook through the present.

    Thanks.

    Tuesday, February 7, 2012 10:06 PM

Answers

All replies

  • You take what MAPI gives you... Always explicilty specify the desired flavor (PT_UNICODE vs PT_STRING8) instead of relying on conditional defines.

    Request both PR_DISPLAY_NAME_W and PR_DISPLAY_NAME_A.

    If PR_DISPLAY_NAME_W is not available (you get prop type of PT_ERROR), fall back to PR_DISPLAY_NAME_A.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Tuesday, February 7, 2012 11:21 PM
  • Ok, I can do that.  How should I handle calls back to mapi, such as

      MAPILogonEx

    Should I always use the char type for the profile name (in this example) returned from the profile query? 

    Thanks.

    Tuesday, February 7, 2012 11:30 PM
  • MAPILogonEx only takes ANSI strings.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    • Marked as answer by perih Wednesday, February 8, 2012 4:37 PM
    Wednesday, February 8, 2012 2:02 PM
  • Thanks!  So, this little part of MAPI is starting to make sense :)
    Wednesday, February 8, 2012 4:16 PM