당신은 비주얼 스튜디오 2010을 사용하고 있다는 가정을 위해 가장 가능성 시작을 내 오른쪽 문서 나 샘플을 조언을 바랍니다 -에서. VSTO 및 Visual Studio에 대한 자세한 내용은 here을 참조하십시오.
일단 실행하고 나면 추가 기능에 "기본 진입 점"이 포함 된 ThisAddIn.cs라는 소스 파일을 갖게됩니다. 거기에서 특정 이벤트가 발생할 때 Outlook에서 발생시키는 이벤트에 연결할 수 있습니다. 당신은 대부분 다음과 같은 이벤트에 관심이있을 것입니다 :
- BeforeFolderSwitch
- FolderSwitch
다음과 같이 보일 것입니다 귀하의 코드 :
귀하의 코드들에 배치해야합니다
private void ThisAddIn_Startup(object sender, EventArgs e)
{
var explorer = this.Application.ActiveExplorer();
explorer.BeforeFolderSwitch += new ExplorerEvents_10_BeforeFolderSwitchEventHandler(explorer_BeforeFolderSwitch);
explorer.FolderSwitch += new ExplorerEvents_10_FolderSwitchEventHandler(explorer_FolderSwitch);
}
/// <summary>
/// Handler for Outlook's "BeforeFolderSwitch" event. This event fires before the explorer goes to
/// a new folder, either as a result of user action or through program code.
/// </summary>
/// <param name="NewlySelectedFolderAsObject">
/// The new folder to which navigation is taking place. If, for example, the user moves from "Inbox"
/// to "MyMailFolder", the new current folder is a reference to the "MyMailFolder" folder.
/// </param>
/// <param name="Cancel">
/// A Boolean describing whether or not the operation should be canceled.
/// </param>
void explorer_BeforeFolderSwitch(object NewlySelectedFolderAsObject, ref bool Cancel)
{
if (NewlySelectedFolderAsObject == null)
return;
var newlySelectedFolderAsMapiFolder = NewlySelectedFolderAsObject as MAPIFolder;
}
void explorer_FolderSwitch()
{
}
이벤트 핸들러를 사용하여 작업을 수행 할 수 있습니다.