共用方式為


取得配置檔中商店的相關信息

此範例示範如何取得和列舉配置檔中的存放區。

範例

注意事項

下列程式代碼範例是 Microsoft Office Outlook 2007 程式設計應用程式的摘錄。

您可以使用 Stores 集合來列舉指定設定檔的存放區。 Stores 集合提供的成員會公開每個 Store 對象的相關信息,例如新增 Store 物件或即將移除目前配置檔中的 Store 物件時。 在下列程式代碼範例中,EnumerateStores 會取得代表目前配置檔中存放區的 Stores 對象,並列舉存放區。 EnumerateStores 會檢查 Stores 集合中的每個 Store 物件。 如果 IsDataFileStore 屬性傳回 true,表示它是 .pst 或 .ost 存放區, DisplayNameFilePath 屬性會寫入接 聽程式 集合中的追蹤接聽程式。

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#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void EnumerateStores()
{
    Outlook.Stores stores = Application.Session.Stores;
    foreach (Outlook.Store store in stores)
    {
        if (store.IsDataFileStore == true)
        {
            Debug.WriteLine(String.Format("Store: "
            + store.DisplayName
            + "\n" + "File Path: "
            + store.FilePath + "\n"));
        }
    }
}

另請參閱