【问题标题】:How to refresh reading pane content in Outlook 2010如何在 Outlook 2010 中刷新阅读窗格内容
【发布时间】:2013-06-03 09:30:01
【问题描述】:

我们使用兑换工具在存根邮件中​​填充真实内容。在选定项目上调用 RDOMail.Import(...) 后,我们使用

关闭并重新打开 Outlook 中的预览(阅读)窗格
m_Explorer.ShowPane(MSOutlook.OlPane.olPreview, false);
m_Explorer.ShowPane(MSOutlook.OlPane.olPreview, true);

此方法在 Outlook 2007 中运行良好。

但在 Outlook 2010 中,编程刷新尝试(关闭/打开阅读窗格,取消选择/选择更新的项目)根本不起作用。 Outlook 2010 仍显示旧版本。

有人有提示或可能的解决方案吗?

非常感谢。

【问题讨论】:

    标签: outlook vsto outlook-addin outlook-2010 outlook-redemption


    【解决方案1】:

    您是否尝试仅在 MailItem 上调用 Close?如果为我选择了该项目,这会刷新内容。似乎是您所建议的更简单的解决方案。

    【讨论】:

      【解决方案2】:

      终于,我们解决了!

      解决办法是

      1) 删除要更新的项目context.RemoveItem(TargetData.EntryID);(我们对 RDOMessage、MailItem、RDOFolder 和 MAPIFolder 使用了一些抽象。但我认为,背后的原理很清楚。

      2) 添加新项目(WithComCleanup 来自VSTOContrib 项目)

      using (var msg = RDOSession.Resource.GetMessageFromMsgFile(pathToMSG)
                                                           .WithComCleanup())
      { 
           msg.Resource.Move(context.RDOFolder);
           msg.Resource.Save();
      }
      

      3) 将 ItemAdd 处理程序附加到 RDOFolderMAPIFolder,注意项目集合必须在类级别声明! 为什么要添加项目?因为RDOMail.OnModifiedRDOMail.OnMoved 都没有提供MailItem 检索所需的有效EntryID。我们在获取时编写自定义 UserAttributes,并在ItemAdd...中读取它们...

       //...
       m_OwnItems = m_Folder.Items
       m_OwnItems.ItemAdd += new MSOutlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
       //...
      
       void Items_ItemAdd(object Item)
       {
           //Outlook 2010: Version 14, only Outlook 2010 supports `ClearSelection` and `AddToSelection`
           if (Item is MSOutlook.MailItem && ApplicationController.Instance.ApplicationVersion.Major >= 14)
           {
               var mail = Item as MSOutlook.MailItem;
      
               //Check that the added item is the one you added with GetMessageFromMsgFile
               //...
      
               if (m_Explorer.IsItemSelectableInView(mail))
               {
                   m_Explorer.ClearSelection();
                   m_Explorer.AddToSelection(mail);
               }
           }    
       }                        
      

      4) 完成了! Outlook 2010 的这种行为在整个开发过程中一直困扰着我们……

      【讨论】:

        【解决方案3】:
        1. 请记住,RDOMail.Move 返回新对象(就像 OOM)。

        2. 由于您正在重新创建消息,因此它的创建时间会发生变化。

        【讨论】:

          猜你喜欢
          • 2018-08-01
          • 2018-10-26
          • 2015-04-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-10-26
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多