繁体   English   中英

在Outlook 2010的加载项中,如何使删除操作可以撤消?

[英]In an add-in for Outlook 2010, how can I make a delete operation undo-able?

我正在为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的“真正”删除功能,以便自动撤消撤消?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM