【问题标题】:Outlook 2010 special folder Add-inOutlook 2010 特殊文件夹加载项
【发布时间】:2012-05-13 03:29:26
【问题描述】:

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

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

请针对我的情况提供正确的文档或样本

【问题讨论】:

    标签: c# ms-office outlook-2010 office-addins


    【解决方案1】:

    假设您使用的是 Visual Studio 2010,您很可能首先创建一个 Visual Studio Tools for Office (VSTO) 项目来创建您的加载项。有关 VSTO 和 Visual Studio 的详细信息,请查看 here

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

    • 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()
    {
    }
    

    您的代码应放置在这些事件处理程序中以执行您的工作。

    【讨论】:

      猜你喜欢
      • 2012-08-24
      • 2022-10-13
      • 2014-05-10
      • 2012-10-14
      • 1970-01-01
      • 2013-07-15
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      相关资源
      最近更新 更多