첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ Folder 인터페이스 : 전체 폴더 경로를 사용해 폴더 구하기 예제

using Microsoft.Office.Interop.Outlook;

Folder folder = GetFolder(Application, @"\\icodebroker@naver.com\받은 편지함");

 

728x90

 

▶ Folder 인터페이스 : 전체 폴더 경로를 사용해 폴더 구하기

using Microsoft.Office.Interop.Outlook;

#region 폴더 구하기 - GetFolder(application, fullFolderPath)

/// <summary>
/// 폴더 구하기
/// </summary>
/// <param name="application">애플리케이션</param>
/// <param name="fullFolderPath">전체 폴더 경로</param>
/// <returns>폴더</returns>
public Folder GetFolder(Application application, string fullFolderPath)
{
    try
    {
        if(fullFolderPath.StartsWith(@"\\"))
        {
            fullFolderPath = fullFolderPath.Remove(0, 2);
        }

        string[] folderPathItemArray = fullFolderPath.Split('\\');

        Folder folder = application.Session.Folders[folderPathItemArray[0]] as Folder;

        if(folder != null)
        {
            for(int i = 1; i <= folderPathItemArray.GetUpperBound(0); i++)
            {
                Folders folders = folder.Folders;

                folder = folders[folderPathItemArray[i]] as Folder;

                if(folder == null)
                {
                    return null;
                }
            }
        }

        return folder;
    }
    catch
    {
        return null;
    }
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요