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

发布于 2024-10-17 00:55:54 字数 745 浏览 3 评论 0原文

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

I am writing an add-in for Outlook 2010. At one point it needs to delete the Mail items currently selected by the user. I'm using the following code, which works quite well:

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();
  }
}

My problem is that when I delete messages this way, the normal "undo" operation is not available to the user. It is possible for the user to go to the Deleted Items folder and move the messages back to the Inbox. But it will be confusing for users that are used to just hitting Ctrl-Z or the little "Undo" arrow at the upper-left corner of the screen.

Is there some way I can register this action with the Undo mechanism, or perhaps invoke the "real" delete functionality of Outlook on the message so that Undo is available automatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江心雾 2024-10-24 00:55:54

不要删除 MailItem;将其移动到 olFolderDeletedItems 文件夹中。您可以使用GetDefaultFolder()来获取对此文件夹的引用;请参阅此处

Don't delete the MailItem; move it to the olFolderDeletedItems folder instead. You can use GetDefaultFolder() to obtain a reference to this folder; see here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文