【问题标题】:Outlook 2010 Add-in - How to determine which MailItem is being shown in the "Reading Pane"Outlook 2010 加载项 - 如何确定“阅读窗格”中显示的 MailItem
【发布时间】:2018-08-01 03:22:55
【问题描述】:

我正在尝试为 Outlook 2010 编写一个插件,它将电子邮件从我的收件箱移动到各种存档文件夹(基于一组过滤条件。

我的主要目标是让我的所有新电子邮件都到达我的收件箱,并且只有在它们被标记为已读并且不再显示在“阅读窗格”中时才会被移动。

在“阅读窗格”中显示新邮件项时是否有事件处理程序?

这些接口之一可以提供帮助吗:

Microsoft.Office.Interop.Outlook.Items
Microsoft.Office.Interop.Outlook.Explorers
Microsoft.Office.Interop.Outlook.Inspectors
Outlook.NavigationPane

【问题讨论】:

    标签: c# outlook-addin outlook-2010


    【解决方案1】:

    您可以使用Explorer.SelectionChange 事件来查看特定消息何时被选中(以及旧消息被取消选中)。

    【讨论】:

      【解决方案2】:

      我使用了Explorer.SelectionChange 事件,它成功了。这是选择新项目时打印电子邮件主题的代码。

          Outlook.Explorer explorer;
      
          private void ThisAddIn_Startup(object sender, System.EventArgs e)
          {
              explorer = Application.ActiveExplorer();
      
              explorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(explorer_SelectionChange);
          }
      
          void explorer_SelectionChange()
          {
              if(0 == Application.ActiveExplorer().Selection.Count)
              {
                  // On start up there are no selections so do nothing...
                  return;
              }
      
              // Get the first mail item
              var item = Application.ActiveExplorer().Selection[1];
      
              //
              if (item is Outlook.MailItem)
              {
                  MessageBox.Show("Selected email's subject: " + ((Outlook.MailItem)item).Subject);
              }
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-16
        • 2011-11-26
        • 2015-04-29
        • 2016-02-17
        • 2019-10-11
        • 2016-11-30
        相关资源
        最近更新 更多