2012-05-03 96 views
0

目前我的目标是创建Outlook加载项,它将创建特定的存档文件夹。与普通的不同之处在于,在我们的入住或搬出过程中,我应该完全控制物品的内容。Outlook 2010特殊文件夹加载项

简而言之,我应该能够在项目的二进制内容真正移动到我的文件夹或从我的文件夹中删除之前扫描它。我想将一些项目复制到网络位置。

请通过为Office(VSTO)创建一个Visual Studio Tools项目指点我右边的文档或样品我的情况

回答

1

假设你使用Visual Studio 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() 
{ 
} 

你的代码应该放在那些事件处理程序来执行您的工作。

相关问题