3

我正在为 Outlook 2010 编写一个加载项。有时它需要删除用户当前选择的邮件项目。我正在使用以下代码,效果很好:

Selection selectedMessages = Globals.ThisAddIn.Application.ActiveExplorer().Selection;

// It is possible for a non-mail item to be part of this collection.  (One example is when a calendar
// item is in the deleted items folder.  Select it and hit this delete button.)
System.Collections.IEnumerator enumerator = selectedMessages.GetEnumerator();
while(enumerator.MoveNext())
{
  if (enumerator.Current is MailItem)
  {
    ((MailItem)(enumerator.Current)).Delete();
  }
}

我的问题是,当我以这种方式删除消息时,用户无法使用正常的“撤消”操作。用户可以转到已删除邮件文件夹并将邮件移回收件箱但对于习惯于按 Ctrl-Z 或屏幕左上角的小“撤消”箭头的用户来说,这会让人感到困惑。

有什么方法可以使用撤消机制注册此操作,或者可能在邮件上调用 Outlook 的“真正”删除功能,以便自动撤消?

4

1 回答 1

1

不要删除MailItem; 而是将其移至olFolderDeletedItems文件夹。您可以使用GetDefaultFolder()来获取对此文件夹的引用;看这里

于 2011-02-10T21:33:50.583 回答