1

我们使用兑换工具在存根邮件中​​填充真实内容。调用RDOMail.Import(...)所选项目后,我们关闭并重新打开 Outlook 中的预览(阅读)窗格,使用

m_Explorer.ShowPane(MSOutlook.OlPane.olPreview, false);
m_Explorer.ShowPane(MSOutlook.OlPane.olPreview, true);

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

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

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

提前谢谢了。

4

3 回答 3

2

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

于 2013-09-24T10:24:29.137 回答
0

最后,我们解决了!

解决方案是

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.OnModified也没有RDOMail.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 的这种行为在整个开发过程中让我们很恼火......

于 2013-06-06T15:02:42.393 回答
0
  1. 请记住,RDOMail.Move 返回新对象(就像 OOM)。

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

于 2013-06-06T15:50:45.423 回答