다음을 통해 공유


프로그래밍 방식으로 이름으로 폴더 검색

이 예제에서는 명명된 사용자 지정 폴더에 대한 참조를 가져온 다음, 폴더의 콘텐츠를 표시합니다.

적용 대상: 이 항목의 정보는 Outlook의 VSTO 추가 기능 프로젝트에 적용됩니다. 자세한 내용은 Office 애플리케이션 및 프로젝트 형식에 따라 사용 가능한 기능을 참조하세요.

예시

private void SetCurrentFolder()
{
    string folderName = "TestFolder";
    Outlook.Folder inBox = (Outlook.Folder)
        Application.ActiveExplorer().Session.GetDefaultFolder
        (Outlook.OlDefaultFolders.olFolderInbox);
    try
    {
        Application.ActiveExplorer().CurrentFolder = inBox.
            Folders[folderName];
        Application.ActiveExplorer().CurrentFolder.Display();
    }
    catch
    {
        MessageBox.Show("There is no folder named " + folderName +
            ".", "Find Folder Name");
    }
}

코드 컴파일

이 예제에는 다음 사항이 필요합니다.

  • TestFolder라는 폴더입니다.