共用方式為


HOW TO:依名稱擷取資料夾

這個範例會取得具名自訂資料夾的參考,然後顯示此資料夾的內容。

**適用於:**本主題中的資訊適用於 Outlook 2007 和 Outlook 2010 的應用程式層級專案。如需詳細資訊,請參閱依 Office 應用程式和專案類型提供的功能

範例

Private Sub SetCurrentFolder()
    Dim folderName As String = "TestFolder"
    Dim inBox As Outlook.MAPIFolder = Me.Application.ActiveExplorer().Session. _
        GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
    Try
        Me.Application.ActiveExplorer().CurrentFolder = inBox.Folders(folderName)
        Me.Application.ActiveExplorer().CurrentFolder.Display()
    Catch
        MsgBox("There is no folder named " & folderName & _
            ".", "Find Folder Name")
    End Try
End Sub
private void SetCurrentFolder()
{
    string folderName = "TestFolder";
    Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
        this.Application.ActiveExplorer().Session.GetDefaultFolder
        (Outlook.OlDefaultFolders.olFolderInbox);
    try
    {
        this.Application.ActiveExplorer().CurrentFolder = inBox.
            Folders[folderName];
        this.Application.ActiveExplorer().CurrentFolder.Display();
    }
    catch
    {
        MessageBox.Show("There is no folder named " + folderName +
            ".", "Find Folder Name");
    }
}

編譯程式碼

這個範例需要:

  • 名為 TestFolder 的資料夾。

請參閱

工作

HOW TO:在特定資料夾中搜尋

HOW TO:搜尋特定的連絡人

HOW TO:建立自訂資料夾項目

概念

使用資料夾