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

▶ CustomAddIn.cs

using Microsoft.Office.Interop.Outlook;
using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 커스텀 애드인
    /// </summary>
    public partial class CustomAddIn
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 탐색기
        /// </summary>
        private Explorer explorer = null;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 커스텀 애드인 시작시 처리하기 - CustomAddIn_Startup(sender, e)

        /// <summary>
        /// 커스텀 애드인 시작시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void CustomAddIn_Startup(object sender, EventArgs e)
        {
            this.explorer = Application.ActiveExplorer();
            
            this.explorer.FolderSwitch    += explorer_FolderSwitch;    // 폴더 선택 변경시
            this.explorer.SelectionChange += explorer_SelectionChange; // 메일 선택 변경시
        }

        #endregion
        #region 커스텀 애드인 셧다운시 처리하기 - CustomAddIn_Shutdown(sender, e)

        /// <summary>
        /// 커스텀 애드인 셧다운시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void CustomAddIn_Shutdown(object sender, EventArgs e)
        {
        }

        #endregion

        #region 탐색기 폴더 스위칭시 처리하기 - explorer_FolderSwitch()

        /// <summary>
        /// 탐색기 폴더 스위칭시 처리하기
        /// </summary>
        private void explorer_FolderSwitch()
        {
            Debug.WriteLine("BEGIN EXPLORER FOLDER SWITCH");

            Debug.WriteLine($"    CURRENT FOLDER : {this.explorer.CurrentFolder.Name}");

            Debug.WriteLine("END EXPLORER FOLDER SWITCH");
        }

        #endregion
        #region 탐색기 선택 변경시 처리하기 - explorer_SelectionChange()

        /// <summary>
        /// 탐색기 선택 변경시 처리하기
        /// </summary>
        private void explorer_SelectionChange()
        {
            Debug.WriteLine("BEGIN EXPLORER SELECTION CHANGE");

            Debug.WriteLine($"    CURRENT FOLDER : {this.explorer.CurrentFolder.Name}");

            foreach(MailItem mailItem in this.explorer.Selection)
            {
                Debug.WriteLine($"    {mailItem.Subject}");
                Debug.WriteLine($"        {mailItem.Sender.Name}");
                Debug.WriteLine($"        {mailItem.SenderEmailType}");
                Debug.WriteLine($"        {mailItem.SenderEmailAddress}");
            }

            Debug.WriteLine("END EXPLORER SELECTION CHANGE");
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region VSTO에서 생성한 코드

        /// <summary>
        /// 디자이너 지원에 필요한 메서드입니다. 
        /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup  += new System.EventHandler(CustomAddIn_Startup );
            this.Shutdown += new System.EventHandler(CustomAddIn_Shutdown);
        }

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

댓글을 달아 주세요