在 Outlook 2010 的加载项中,如何使删除操作可撤消?
我正在为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要删除
MailItem
;将其移动到olFolderDeletedItems
文件夹中。您可以使用GetDefaultFolder()
来获取对此文件夹的引用;请参阅此处。Don't delete the
MailItem
; move it to theolFolderDeletedItems
folder instead. You can useGetDefaultFolder()
to obtain a reference to this folder; see here.