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:
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;
typedef enum _SearchPathReorderType
{
SEARCHPATHREORDERTYPE_RAW = 0,
SEARCHPATHREORDERTYPE_ACCT_PREFERGAL,
SEARCHPATHREORDERTYPE_ACCT_PREFERCONTACTS,
} SearchPathReorderType;
Finally, here's a description of each of the settings:
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
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!
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);
}
return 2; // cant get the prop
lpProfileSection->Release();
return 1; // cant connect to IID_CAPONE_PROF
yair.glikman@rtc-vision.com
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
You left out the &:
if (FAILED ( hRes = lpSession->OpenProfileSection((LPMAPIUID)&IID_CAPONE_PROF, NULL, MAPI_MODIFY, &lpProfSect)))
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 ?
That's discussed here: support.microsoft.com/.../130869
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 ?
I found the solution for my last question.
Here the code if someone have the same problem.
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;