You Chose…Wisely


In Outlook 2010, there’s a new feature in the Address Book which I’ll call “Choose automatically”. You’ll find it in the Address Book in Tools/Options under the section “When opening the address book, show this address list first:”. It looks like this:

Address Book Options Showing Choose Automatically Feature

We added this feature to support MultiEx. Before we put the feature in, if you had multiple Exchange mailboxes in the profile, you could only pick one GAL to be your default. If your current mailbox didn’t use that GAL, tough. With “Choose automatically” enabled, Outlook will pick the most appropriate GAL or contact folder for the current mailbox.

I’ll leave the details about which address book gets selected here to someone else. The key issue from a MAPI perspective is that with “Choose automatically” enabled, the Address Book dialog no longer defaults to the container specified by SetDefaultDir. This can result in a poor experience for third party address book providers. Fortunately, you can turn “Choose automatically” off via a setting in the profile.

You’ll find the setting in the IID_CAPONE_PROF profile section. This profile section is widely known on the Internets, but hasn’t been documented before. Here’s the definition:

// Capone profile section
// {00020D0A-0000-0000-C000-000000000046}
DEFINE_OLEGUID(IID_CAPONE_PROF, 0x00020d0a, 0, 0);

You can open that profile section and toggle the feature on and off by setting the PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY property:

#define PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY PROP_TAG( PT_BOOLEAN, 0x3D1C)

That’s all there is to it. You don’t even have to restart Outlook, though if you have the Address Book open it obviously won’t take effect until you close and reopen it.

Enjoy!

Comments (5)

  1. Huang says:

    Would you provide a sample code to set it off?

  2. Priya says:

    Hi Griffin:

    Could you please tell how i can open the IID_CAPONE_PROF profile section? In my application .cpp file i added the below line

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

    Then i am callling the OpenProfileSection method with the below call:

    // open profile

    if (FAILED ( hRes = lpSession->OpenProfileSection((IID_CAPONE_PROF), NULL, NULL, &lpProfSect)))goto Error;

    It gives me compile time error

    Error 1 error C2664: 'IMAPISession::OpenProfileSection' : cannot convert parameter 1 from 'const GUID' to 'LPMAPIUID'

    When i try to type case the same it gives me below compile time error

    Error 1 error C2440: 'type cast' : cannot convert from 'const GUID' to 'LPMAPIUID'

  3. Stephen Griffin says:

    OpenProfileSection wants a pointer to the ID, not the ID itself. So you need to pass &IID_CAPONE_PROF.

  4. OCSUser says:

    Hi Stephen,

    I have implemented the code and it didn't work if the profile has not changed the address book before.

    Test 1: (Success)

    1. Open the outlook 2010

    2. Change "When opening the address book, show this address list first" from "CHOOSE AUTMOATICALLY" to One of the contacts

    3. Close Outlook 2010 and launch 2010 again.

    4. Run the program to change the address book to the other one

    5. Open the address book and the contacts have been changed.

    6. Open the address book again and change it to "Choose Automatically"

    7. Close Outlook 2010 and run the program again

    8. Open outlook 2010 and address book, the contacts have been changed.

    Test 2: (Failed)

    1. Create a new Profile

    2. Open Outlook 2010

    3. Close Outlook 2010 and run the program to change the default address

    4. Open outlook 2010

    5. The address book didn't change and remain on Choose automatically

    In the above result, it seems that the default address book need to be changed in the first time of the profile then the program can reset it's order from "Choose Automatically" to the other contacts. Why would it happen? As I have already reset the PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY already…

    The below is the coding

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

    #define PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY PROP_TAG( PT_BOOLEAN, 0x3D1C)

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

    if (SUCCEEDED ( hr = HrGetOneProp(lpProfileSection, PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY, &lpPropValue))){

    lpPropValue->Value.l = 0;

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

  5. sureshh says:

    Hello Stephen Griffin,

    I am new to this and just wondering if there is equivalent code in C#.NET that we can use to implement similar functionality.

    Please advise.