programmatically chanage general outlook settings

L

lyle dodge

I downloaded and ran OutlookSpy, but I can't find how to change the settings
in the property pages under Tools / Options. Specifically, I'm trying to
manipulate the signatures. Has anybody been able to change any of the
property pages under Tools / Options?
 
K

Ken Slovak

You can't. They aren't exposed to you. If you want to work with signatures
directly you can by working from where they are stored in the file system.
 
T

Tom Winter

This code may get you started manipulating signatures in Outlook. Each
version of Outlook does things differently. 2000 and 2003 store signatures
separetly for each profile. 2002 does not. 2003 requires a restart after
changing the registry setting before it will pick it up. I have not included
the code for setting/getting registry values, but you should get the idea.
Unfortunately Outlook often likes to store things in the registry using
REG_EXPAND_SZ and REG_BINARY, which can be a pain.

Private Sub SetOutlookSignature2000(sSignature As String, sProfile As
String)

On Error GoTo ErrorHandler

Dim sRegistryPath As String

sRegistryPath = GetProfilesRegistryPath() & sProfile &
"\0a0d020000000000c000000000000046"

If Not SetRegistryValue(HKEY_CURRENT_USER, sRegistryPath,
"001e0361", sSignature) Then

' Do something with the error...

End If

Exit Sub

ErrorHandler:

' Do something with the error...

End Sub

Private Sub SetOutlookSignature2002(sSignature As String)

On Error GoTo ErrorHandler

' Outlook 2002 stores the signature name as REG_EXPAND_SZ.

If Not SetRegistryValue(HKEY_CURRENT_USER,
"Software\Microsoft\Office\10.0\Common\MailSettings", "NewSignature",
sSignature, REG_EXPAND_SZ) Then

' Do something with the error...

End If

Exit Sub

ErrorHandler:

' Do something with the error...

End Sub

Private Sub SetOutlookSignature2003(sSignature As String, sProfile As
String)

On Error GoTo ErrorHandler

Dim sRegistryPath As String

Dim lAccounts() As Long

Dim lAccountIterator As Long

Dim lAccount As Long

sRegistryPath = GetProfilesRegistryPath() & sProfile &
"\9375CFF0413111d3B88A00104B2A6676\"

lAccounts = GetOutlookAccounts2003(sProfile)

For lAccountIterator = LBound(lAccounts) To UBound(lAccounts)

lAccount = lAccounts(lAccountIterator)

If Not SetRegistryValue(HKEY_CURRENT_USER, sRegistryPath &
FormatLongToHex(lAccount), "New Signature", sSignature, REG_BINARY) Then

' Do something with the error...

End If

Next

Exit Sub

ErrorHandler:

' Do something with the error...

End Sub

Public Function GetProfilesRegistryPath() As String

On Error GoTo ErrorHandler

' This returns the registry path where MAPI/Outlook store
information about
' profiles. Right under this path there is a sub-key for each
profile.
' This path is different for 95/98/ME versus NT/2000/XP/2003.

If IsWindowsNT() Then

GetProfilesRegistryPath = "Software\Microsoft\Windows
NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

Else

GetProfilesRegistryPath = "Software\Microsoft\Windows Messaging
Subsystem\Profiles\"

End If

Exit Function

ErrorHandler:

' Do something with the error...

End Function

Public Function GetOutlookAccounts2003(sProfile As String) As Long()

On Error GoTo ErrorHandler

' Outlook 2003 stores signature information separately for each
e-mail account
' defined, so we need to get a list of those accounts. This function
returns
' an array of longs, each of which is an account number.

Dim sRegistryPath As String

Dim vAccounts As Variant

' This path is where all of the account information is stored. Under
this path
' there is a sub-key for each account, directory (address book) and
data file.

sRegistryPath = GetProfilesRegistryPath() & sProfile &
"\9375CFF0413111d3B88A00104B2A6676\"

' Here, GetRegistryValue returns an array of longs, each of which is
an account number.

' This registry value contains a list of which sub-keys are e-mail
accounts.

vAccounts = GetRegistryValue(HKEY_CURRENT_USER, sRegistryPath,
"{ED475418-B0D6-11D2-8C3B-00104B2A6676}", Empty, vbLong)

If Not IsEmpty(vAccounts) Then

GetOutlookAccounts2003 = vAccounts

Else

' Do something with the error...

End If

Exit Function

ErrorHandler:

' Do something with the error...

End Function
 
L

lyle dodge

It's working great. Thanks for the code snippet. You came up with the
answer when so many other people said it couldn't be done. So... do you know
where the settings are stored for stationary? I couldn't see any keys that
are stored under their profile in the same key as "New Signature" and
"Reply-Forward Signature"...

Lyle
 
T

Tom Winter

I haven't actually worked with stationery in the same way. You might be able
to do what I did in order to figure it out though. I used RegMon
(http://www.sysinternals.com/ntw2k/source/regmon.shtml) to create a log of
registry changes that Outlook makes when I click the OK button in the TOOLS
| OPTIONS window. (I also did a heck of a lot of searching around on
google.) You'll have to have three different computers, each with a
different version of Outlook, since each is likely to store things
differently. If you find a good solution, please post it to the newsgroup so
every one can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top