C# Outlook 2010特殊文件夹加载项

C# Outlook 2010特殊文件夹加载项,c#,ms-office,outlook-2010,office-addins,C#,Ms Office,Outlook 2010,Office Addins,目前我的目标是创建Outlook加载项,它将创建特定的存档文件夹。与常规的不同之处在于,在项目移入或移出期间,我的项目应该为我提供对项目内容的完全控制 简单地说,我应该能够扫描项目的二进制内容之前,它真正移动到我的文件夹或从我的文件夹中删除。我将把其中一些项目复制到NetworkPlace 请为我的情况提供正确的文档或示例假设您使用的是Visual Studio 2010,您很可能首先创建Visual Studio Tools for Office(VSTO)项目来创建外接程序。查看VSTO和V

目前我的目标是创建Outlook加载项,它将创建特定的存档文件夹。与常规的不同之处在于,在项目移入或移出期间,我的项目应该为我提供对项目内容的完全控制

简单地说,我应该能够扫描项目的二进制内容之前,它真正移动到我的文件夹或从我的文件夹中删除。我将把其中一些项目复制到NetworkPlace


请为我的情况提供正确的文档或示例

假设您使用的是Visual Studio 2010,您很可能首先创建Visual Studio Tools for Office(VSTO)项目来创建外接程序。查看VSTO和Visual Studio的详细信息

一旦启动并运行该插件,就会有一个名为ThisAddIn.cs的源文件,其中包含外接程序中的“主入口点”。从那里,您可以连接到Outlook在某些事件发生时将引发的事件。您很可能会对以下事件感兴趣:

  • 前折叠开关
  • 折叠开关
您的代码将如下所示:

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()
{
}
private void ThisAddIn\u启动(对象发送方,事件参数e)
{
var explorer=this.Application.ActiveExplorer();
explorer.BeforeFolderSwitch+=新的ExplorerEvents\u 10\u BeforeFolderSwitchEventHandler(explorer\u BeforeFolderSwitch);
explorer.FolderSwitch+=新的ExplorerEvents\u 10\u FolderSwitchEventHandler(explorer\u FolderSwitch);
}
/// 
///Outlook的“BeforeFolderSwitch”事件的处理程序。此事件在资源管理器转到之前激发
///由于用户操作或通过程序代码创建的新文件夹。
/// 
/// 
///正在对其进行导航的新文件夹。例如,如果用户从“收件箱”移动
///对于“MyMailFolder”,新的当前文件夹是对“MyMailFolder”文件夹的引用。
/// 
/// 
///描述是否应取消操作的布尔值。
/// 
void explorer\u BeforeFolderSwitch(对象新建选定FolderSobject,参考bool取消)
{
if(NewlySelectedFolderAsObject==null)
返回;
var newlySelectedFolderAsMapiFolder=newlySelectedFolderAsMapiFolder;
}
void explorer_FolderSwitch()
{
}
您的代码应该放在这些事件处理程序中以执行您的工作