Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

       How did you like this article? Please vote and let us know.          

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Shannal L. Thomas
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath

 

 
  Programmatically changing Mail Settings in MS Outlook.
Programmatically changing Mail Settings in MS Outlook.
MSDN says: "The Outlook object model provides all of the functionality necessary to manipulate data stored in Outlook folders. However, there is limited functionality available to control Outlook itself. For example, there is no programming method to change the Options settings on the Tools menu, in Outlook via the object model".
So we'll have to change some registry settings. Outlook creates these settings in the registry after first start with a specified profile. After this we can take a control over it.

This article is dedicated to enabling and disabling transports in Options/Mail Services/Mail options/Check for new mail on.

The path to keys that we'll need depends on operating system version.
For Windows 95:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Windows Messaging Subsystem\Profiles\<Profile Name>\0a0d020000000000c000000000000046
For Windows 98/ME:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows Messaging Subsystem\Profiles\<Profile Name>\0a0d020000000000c000000000000046
For Windows 2000/NT:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<Profile Name>\0a0d020000000000c000000000000046
Now these keys are keeping what we need: "10030239" and "101e0250"
10030239 contains information on whether a transport is checked/unchecked. For each transport there is a four byte value contained 1 in first byte.
For example a value: 01 00 00 00 00 00 00 00 01 00 00 00 means that first and third transports are enabled (checked) and the second one is disabled (unchecked).
Of course what a sense to change these values if you don't know what transport belongs to each four byte value. That the 101e0250 key is for. It contains header with 12 bytes, the first bytes shows the number of transports. Since 13-th byte the key contains an array of strings (C-style, each finished with 0) with transport names as they are shown in the Outlook Mail Options.
So the algorithm of enabling/disabling transports is as follows:
- Find a list of transports for a profile (and specified service for example). Read my articles about profiles programming to learn how to get a table with specified properties. In this case use PR_RESOURCE_TYPE, it should be equal to 36 for transport provider.
- Find the desired transport name in the 101e0250 key and remember its position number.
- Change iPosition*4 byte to 1 or 0 according to what you need.
- That's it. Start the Outlook and see the result.

Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Pro Exchange. OutlookExchange.Com and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

© Copyright Pro Exchange, Inc., 2006