How to: Get Information About Stores in a Profile
This example shows how to get and enumerate stores in a profile.
The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).
You can use the Stores collection to enumerate the stores for a given profile. The Stores collection provides members that expose information about each Store object, such as when a Store object has been added or when a Store object is about to be removed in the current profile. In the following code example, EnumerateStores gets the Stores object that represents stores in the current profile, and enumerates the stores. EnumerateStores examines each Store object in the Stores collection. If the IsDataFileStore property returns true, indicating that it is a .pst or .ost store, the DisplayName and FilePath properties are written to the trace listeners in the Listeners collection.
If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.