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:
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
Anonymous
February 25, 2011
Would you provide a sample code to set it off?Anonymous
October 02, 2011
The comment has been removedAnonymous
October 02, 2011
OpenProfileSection wants a pointer to the ID, not the ID itself. So you need to pass &IID_CAPONE_PROF.Anonymous
January 07, 2012
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)
- Open the outlook 2010
- Change "When opening the address book, show this address list first" from "CHOOSE AUTMOATICALLY" to One of the contacts
- Close Outlook 2010 and launch 2010 again.
- Run the program to change the address book to the other one
- Open the address book and the contacts have been changed.
- Open the address book again and change it to "Choose Automatically"
- Close Outlook 2010 and run the program again
- Open outlook 2010 and address book, the contacts have been changed. Test 2: (Failed)
- Create a new Profile
- Open Outlook 2010
- Close Outlook 2010 and run the program to change the default address
- Open outlook 2010
- 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))) ...
- Anonymous
May 15, 2015
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.