• Sign in
 
  •  
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • Blog Home
  • About
  • Email Blog Author
  • Share this
  • RSS for posts
  • Atom
  • RSS for comments
  • CDO (25)
  • Code Snippet (43)
  • Custom Providers (17)
  • Debugging (7)
  • DevMsgTeam (301)
  • Documentation (109)
  • DST (8)
  • EWS (7)
  • Exchange (109)
  • Gotchas (97)
  • Hotfix (28)
  • MAPI (240)
  • MAPI Download (54)
  • MFCMAPI (101)
  • MSDN (59)
  • Non Dev (11)
  • OOM (17)
  • Outlook (171)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (12)
  • Protocol Docs (20)
  • PST/OST (23)
  • Referrals (8)
  • Vista (12)
  • WrapPST (18)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2013 (3)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (2)
  • January 2013 (2)
  • December 2012 (4)
  • November 2012 (2)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (3)
  • June 2012 (2)
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)

SetSearchPath? Not Really

MSDN Blogs > SGriffin's MAPI Internals > SetSearchPath? Not Really

SetSearchPath? Not Really

Stephen Griffin - MSFT
13 Apr 2011 10:35 AM
  • Comments 7

This is a follow up to our documentation on PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY. There, we discussed how Outlook 2010 has a property which can override the container specified in SetDefaultDir. Today, we’re going to override SetSearchPath. Let’s look at our dialog again:

Address Book Tools Options Dialog

That list of address books under Custom is what we set using SetSearchPath. How can we set “Start with Global Address List” or “Start with contact folders”? There’s a prop for that: PR_AB_SEARCH_PATH_CUSTOMIZATION, which you’ll find in the same place as PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY, on the profile section IID_CAPONE_PROF.

Here's the property definition:

#define PR_AB_SEARCH_PATH_CUSTOMIZATION( PT_LONG, 0x3D1B)

Here are the valid settings:

typedef enum _SearchPathReorderType
{
                SEARCHPATHREORDERTYPE_RAW = 0,
                SEARCHPATHREORDERTYPE_ACCT_PREFERGAL,
                SEARCHPATHREORDERTYPE_ACCT_PREFERCONTACTS,
} SearchPathReorderType;

Finally, here's a description of each of the settings:

  • SEARCHPATHREORDERTYPE_RAW:
    Return a list of the containers that are in the persisted MAPI search path. This is the "Custom" search path option in the UI.
  • SEARCHPATHREORDERTYPE_ACCT_PREFERGAL:
    Group the search path based on the mail accounts in the profile, prefer the given sending account, and within each account, prefer the GAL. An example reordering here sending from account B would be the following:

    Persisted search Path:
    Contacts A
    GAL A
    GAL B
    GAL C
    Contacts D
    Contacts D2
    Contacts C
    Contacts B

    Reordered Search Path sending from B with this option:
    GAL B
    Contacts B
    GAL A
    Contacts A
    GAL C
    Contacts C
    Contacts D
    Contacts D2

  • SEARCHPATHREORDERTYPE_ACCT_PREFERCONTACTS
    Group the search path based on the mail accounts in the profile, prefer the given sending account, and within each account, prefer that account's contacts folders. An example reordering here sending from account B would be the following:

    Persisted search Path:
    Contacts A
    GAL A
    GAL B
    GAL C
    Contacts D
    Contacts D2
    Contacts C
    Contacts B

    Reordered Search Path sending from B with this option:
    Contacts B
    GAL B
    Contacts A
    GAL A
    Contacts C
    GAL C
    Contacts D
    Contacts D2

Enjoy!

  • 7 Comments
Exchange, Outlook, MAPI, Documentation, Custom Providers, DevMsgTeam, MSDN
Comments
  • Yair Glikman
    22 Nov 2011 7:44 AM

    here is the code...

    DEFINE_OLEGUID(IID_CAPONE_PROF, 0x00020d0a, 0, 0);

    #define PR_AB_SEARCH_PATH_CUSTOMIZATION PROP_TAG( PT_LONG, 0x3D1B)

    #define PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY PROP_TAG( PT_BOOLEAN, 0x3D1C)

    int SetCustominzation(IMAPISession &lpSession) {

      HRESULT hr;

      LPPROFSECT lpProfileSection = NULL;

      LPSPropValue lpPropValue = NULL;

      LONG FAR * ulPropCnt = NULL;

      LPSPropValue FAR * pProps = NULL;

      hr = lpSession.OpenProfileSection((LPMAPIUID)&IID_CAPONE_PROF, NULL, MAPI_MODIFY  , &lpProfileSection);

    if (hr == S_OK) {

    //if (SUCCEEDED ( hr = HrGetOneProp(lpProfileSection, PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY, &lpPropValue))) good for select auto

    if (SUCCEEDED ( hr = HrGetOneProp(lpProfileSection, PR_AB_SEARCH_PATH_CUSTOMIZATION, &lpPropValue)))

    {

    //printf("Server DN: %d\n", lpPropValue->Value.b); for good select auto

    lpPropValue->Value.l = 0;

    if (SUCCEEDED(hr = HrSetOneProp(lpProfileSection, lpPropValue)))

    return S_OK; // good

    else

    return 3;

    MAPIFreeBuffer(lpPropValue);  

    }    

    else

    return 2; // cant get the prop

    lpProfileSection->Release();

    }

    else

    return 1; // cant connect to IID_CAPONE_PROF

    }

    yair.glikman@rtc-vision.com

  • Jean
    23 Nov 2012 3:25 AM

    First of all, sorry for my English.

    I try to set the profile configuration.

    I found how to set the Resolution Order for Address Lists, but I need now to set

    PR_AB_SEARCH_PATH_CUSTOMIZATION to "Custom".

    I use Visual C++ 2008 Express

    I have an error "error C2440: 'cast de type' : impossible de convertir de 'const GUID' en 'LPMAPIUID'"

    on the line

    if (FAILED ( hRes = lpSession->OpenProfileSection((LPMAPIUID)IID_CAPONE_PROF, NULL, MAPI_MODIFY, &lpProfSect)))

    I normaly work with C# and I don't understand what I miss here.

    Thanks

    Jean

    {

  • Stephen Griffin - MSFT
    26 Nov 2012 5:44 AM

    You left out the &:

    if (FAILED ( hRes = lpSession->OpenProfileSection((LPMAPIUID)&IID_CAPONE_PROF, NULL, MAPI_MODIFY, &lpProfSect)))

  • Jean
    28 Nov 2012 11:17 PM

    Hello, and thanks for your answer.

    I get this error when I try with the syntax with "&IID_CAPONE_PROF"

    --------

    1>ChangeAddressBookListOrder32.obj : error LNK2001: symbole externe non résolu _IID_CAPONE_PROF

    1>C:\ChangeAddressBookListOrder32\Debug\ChangeAddressBookListOrder32.exe : fatal error LNK1120: 1 externes non résolus

    ---------

    have you an idea ?

    Thanks

    Jean

  • Stephen Griffin - MSFT
    29 Nov 2012 5:51 AM

    That's discussed here: support.microsoft.com/.../130869

  • Jean
    30 Nov 2012 7:43 AM

    Hello,

    I have another question.

    The code works well when user has at least selects one time the radio button "Custom". But if it's a new profile, the is an error on "HrGetOneProp(lpProfSect,PR_AB_SEARCH_PATH_CUSTOMIZATION, &lpPropValue)".

    How can I initialise this property the first time ?

    Thanks

    Jean

  • Jean
    30 Nov 2012 8:13 AM

    I found the solution for my last question.

    Here the code if someone have the same problem.

    Thanks

    Jean

    if (FAILED ( hRes = HrGetOneProp(lpProfSect,PR_AB_SEARCH_PATH_CUSTOMIZATION, &lpPropValue)))

    {

    printf ("Fatal Error: failed to get property PR_AB_SEARCH_PATH_CUSTOMIZATION %d try to creat a new one \n",hRes);

    SPropValue  spvEID_Ex;

    spvEID_Ex.ulPropTag = PR_AB_SEARCH_PATH_CUSTOMIZATION;

    spvEID_Ex.Value.l = 0;

    if (FAILED ( hRes = HrSetOneProp(lpProfSect, &spvEID_Ex)))

    {

    printf ("Fatal Error: failed to create a new one  %d \n",hRes);

    lngReturn = -11;

    goto Cleanup;

    }

    }

Page 1 of 1 (7 items)
Leave a Comment
  • Please add 7 and 6 and type the answer here:
  • Post
  • © 2013 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy & Cookies
  • Report Abuse
  • 5.6.426.415