'Programmatically configure Outlook's options for address lists
I need to to programmatically (ideally via PowerShell) configure Outlook setting the options:
- "When sending e-mail, check address lists in this order:" to "Start with contact folders".
- "When opening the address book, show this address list first:" to "Outlook Address Book".
This problem has proved particularly elusive and I have been investigating this over the course of many hours so my consolidated findings may seem a bit thrown together.
Option #1
If I recall correctly, the following PowerShell commands successfully configured the options:
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b3d1c" -PropertyType "Binary" -Value 0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "00033d1b" -PropertyType "Binary" -Value 0x02,0x00,0x00,0x00 -Force;
Option #2
Exporting the registry key HKCU\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>
to a REG file, recreating the mail profile, importing the REG file, and opening Outlook shows that the options are set as desired. So, it can be done via the registry.
Process Monitor, configured to monitor registry operations with filters Process Name is OUTLOOK.EXE Include
and Operation is RegSetValue Include
, always outputs slightly different results but the consistent results are:
15:48:56.9983649 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\9207f3e0a3b11019908b08002b2a56c2\01023d06 SUCCESS Type: REG_BINARY, Length: 44, Data: 00 00 00 00 FE 42 AA 0A 18 C7 1A 10 E8 85 0B 65
15:48:56.9991115 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\000b3d1c SUCCESS Type: REG_BINARY, Length: 2, Data: 00 00
15:48:56.9996963 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\00033d1b SUCCESS Type: REG_BINARY, Length: 4, Data: 02 00 00 00
15:48:57.0052360 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\4ae4e14443f96d4982c25a0b9340e560\000b048b SUCCESS Type: REG_BINARY, Length: 2, Data: 01 00
15:49:03.0985853 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\1102039b SUCCESS Type: REG_BINARY, Length: 308, Data: 01 00 00 00 1D 01 00 00 00 00 00 00 14 00 00 00
15:49:03.0990695 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\000b0415 SUCCESS Type: REG_BINARY, Length: 2, Data: 00 00
However, the following PowerShell commands did not successfully configure the options:
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b046b" -PropertyType "Binary" -Value 0x01,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\9207f3e0a3b11019908b08002b2a56c2\" -Name "01023d06" -PropertyType "Binary" -Value 0x00,0x00,0x00,0x00,0xFE,0x42,0xAA,0x0A,0x18,0xC7,0x1A,0x10,0xE8,0x85,0x0B,0x65 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b3d1c" -PropertyType "Binary" -Value 0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "00033d1b" -PropertyType "Binary" -Value 0x02,0x00,0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b0340" -PropertyType "Binary" -Value 0x01,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\9207f3e0a3b11019908b08002b2a56c2\" -Name "11023d05" -PropertyType "Binary" -Value 0x02,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\b9e1c8a47102f24688ede3f23cbc5224\" -Name "0102663b" -PropertyType "Binary" -Value 0x0F,0x00,0x01,0x00,0x8C,0x01,0x21,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "1102039b" -PropertyType "Binary" -Value 0x01,0x00,0x00,0x00,0x1D,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b0415" -PropertyType "Binary" -Value 0x00,0x00 -Force;
Set Outlook's 'show this address list first' option suggests that this can be done by use of ComObjects but tests showed that Outlook detected the activity as malicious and prompted with a security warning that required manual intervention, which, obviously, is problematic in that it is not 100 % programmatic.
https://social.technet.microsoft.com/Forums/exchange/en-US/85a392d4-fc85-43c5-9c02-c07ec86e2ade/default-address-list?forum=exchangesvrclientslegacy and https://social.technet.microsoft.com/Forums/office/en-US/6bb9b40f-b794-41ce-93b4-711e77c53607/gal-default-adress-book-gpo says that registry key *\<mail profile name>\9207f3e0a3b11019908b08002b2a56c2
-> value 01023d06
is responsible which was detected by Process Monitor but, as referenced above, it has not worked in my testing.
Solution 1:[1]
That option is set using IAddrBook.SetDefaultDir and IAddrBook.SetSearchPath in Extended MAPI (C++ or Delphi only). Outlook Object Model does not expose that functionality. If using Redemption is an option (I am its author - any language), it exposes the RDOAddressBook.DefaultAddressList
and SearchPath
properties.
Solution 2:[2]
I wrote this PS script to change "When opening the address book, show this address list first:"
## Script for setting default address book view in Outlook for CU
#
# Input (const):
# <$cAddrList> GUID for needed address list
# Dump REG_BINARY value of '01023d06' from key
# HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles\Outlook\9207f3e0a3b11019908b08002b2a56c2\
#
# Version 1.2
# (c)kMit 2017
#
#AddressList string - 'BigBoxList'
$cAddrList = 'fe000000000000000000000000000000000000ff01000000000100002f677569643d393536324239433038413232374234454236313831443644364236323635353100'
#Outlook profiles registry path
$cMSOProf = '\Software\Microsoft\Office\15.0\Outlook\Profiles\'
$cMSOPFil = '*Outlook'
$cMSORK01 = '\9207f3e0a3b11019908b08002b2a56c2'
$cMSORSrc = '11023d05'
$cMSORTrg = '01023d06'
$cMSORK02 = '\0a0d020000000000c000000000000046'
$cMSORBFM = '000b3d1c'
#\''
#Get list of Outlook profiles
$pList = (Get-ChildItem -Path HKCU:$cMSOProf -ErrorAction SilentlyContinue)
#Select profile - profile name doesn't matter if it's single, or the first one that matches $cMSOPFil
if($pList) {
if($pList.GetType().BaseType.Name -eq 'Array') {
$pTarg = ($pList | ? {$_.Name -like $cMSOPFil})[0]
} else {
$pTarg = $pList
}
}
#Change profile
if($pTarg -and (Get-ChildItem HKCU:$pTarg -ErrorAction SilentlyContinue)) {
$rKey = 'HKCU:'+$pTarg.Name.Substring(17)
try {
$is = (Get-ItemProperty -Path ($rKey+$cMSORK01)).$cMSORSrc
#Make value and copy header
$it = @(($cAddrList -split '([a-f0-9]{2})') | ForEach-Object {if($_) {[System.Convert]::toByte($_,16)}})
for($i=0;$i -lt 20;$i++) {$it[$i] = $is[$i+20]}
#Write result
Set-ItemProperty -Path ($rKey+$cMSORK01) -Name $cMSORTrg -Type Binary -Value ([byte[]]($it))
#Disable auto-select ('Choose automatically')
Set-ItemProperty -Path ($rKey+$cMSORK02) -Name $cMSORBFM -Type Binary -Value ([byte[]](0,0))
}
catch {
break
}
}
Solution 3:[3]
Partial answer here, addressing how to change the first setting requested by the OP.
The setting When sending e-mail, check address lists in this order can be changed by modifying the following the Registry as follows:
Key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\[OutlookVersion]\Outlook\Profiles\[OutlookProfileName]\0a0d020000000000c000000000000046
- [OutlookVersion] is the version of Outlook (e.g.
15.0
) - [OutlookProfileName] is the user's Outlook profile name (e.g.
Outlook
).
Value name: 00033d1b
(type: REG_BINARY)
Data:
01 00 00 00
enables Start with Global Address List02 00 00 00
enables Start with contact folders
PowerShell to Change Setting
Assuming Outlook 15.0 and a profile name of "Outlook":
Enable Start with Global Address List:
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Profiles\Outlook\0a0d020000000000c000000000000046\" -Name 00033d1b -Value ([byte[]](0x01,0x00,0x00,0x00))
Enable Start with contact folders:
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Profiles\Outlook\0a0d020000000000c000000000000046\" -Name 00033d1b -Value ([byte[]](0x02,0x00,0x00,0x00))
Notes:
- This can be changed while Outlook is open; the change takes effect immediately.
- Use of
Set-ItemProperty
assumes the value00033d1b
already exists in the Registry. - Credit to this SO answer for explaining how to use the
[byte[]]
syntax. - Credit to this SO question for providing a starting place for finding this answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | |
Solution 3 | Community |