更新:2007 年 11 月
| 适用对象 | 
|---|
| 本主题中的信息仅适用于指定的 Visual Studio Tools for Office 项目和 Microsoft Office 版本。 项目类型 
 Microsoft 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
        MessageBox.Show("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 的文件夹。