Outlook 2010 特殊文件夹加载项
本文关键字:文件夹 加载项 2010 Outlook | 更新日期: 2023-09-27 18:32:59
目前我的目标是创建Outlook加载项,这将创建特定的存档文件夹。与常规项目的区别在于,我的应该让我在搬入或搬出期间完全控制项目的内容。
简而言之,我应该能够在项目的二进制内容真正移动到我的文件夹中或从我的文件夹中删除之前扫描项目的二进制内容。我将把其中一些项目复制到网络位置。
请根据我的情况提供正确的文档或样品
> 假设您使用的是 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()
{
}
应将代码放置在这些事件处理程序中以执行工作。