使用 Exchange 中的 EWS 删除项目Deleting items by using EWS in Exchange

了解如何在 Exchange 中使用 EWS 托管 API 或 EWS 通过将项目移动到 "已删除邮件" 文件夹或转储程序来删除项目。Find out how you can use the EWS Managed API or EWS in Exchange to delete items either by moving them to the Deleted Items folder or to the dumpster.

您是否曾问自己,在将项目移动到 "已删除邮件" 文件夹之间有什么区别,并将它们移动到转储程序?Have you ever asked yourself what the difference is between moving items to the Deleted Items folder, and moving them to the dumpster? 您可能希望了解处理已删除项目的不同选项以及如何在应用程序中实现这些选项。You might be curious about the different options for handling deleted items and how to implement those options in your application. Exchange Web 服务(EWS)包括用于处理已删除项目的三个选项。Exchange Web Services (EWS) includes three options for handling deleted items. 本文将向你表明你可能会遇到的任何有关它们之间的差异的混乱。This article will hopefully clear up any confusion you might have about the differences between them.

删除项目-什么是我的选项?Deleting items - what are my options?

必须先了解以下各项之间的差异,然后才能了解用于删除项目的总体前景:Before you can understand the overall landscape for deleting items, it's important to recognize the difference between the following:

  • "已删除邮件" 文件夹-当您删除邮箱中的邮件时,这就是他们要转到的位置。The Deleted Items folder - When you delete items in a mailbox, this is where they go.

  • 转储程序(也称为 "可恢复项目" 文件夹)-当您从邮箱中删除项目时,这就是他们要转到的位置。The dumpster (aka the Recoverable Items folder) - When you remove items from a mailbox, this is where they go.

图1和图2显示了删除过程对邮箱中的项目和文件夹的外观。Figures 1 and 2 show what the deletion process looks like for items and folders in a mailbox.

图1。删除邮箱中的项目的过程Figure 1. Process for deleting items from a mailbox

此说明显示邮件去向和删除时间。


图2。从邮箱中删除文件夹的过程Figure 2. Process for deleting folders from a mailbox

此说明显示如何将已删除文件夹移动到“已删除邮件”文件夹,从而可以从邮箱中永久删除。

您可以通过三种不同的方式删除项目和文件夹,具体取决于您希望删除的 "永久" 方式。You can delete items and folders three different ways, depending on how "permanent" you would like the deletion to be.

表1:使用 EWS 删除项目的选项Table 1: Options for deleting items by using EWS

选项Option 发生的情况What happens
移动到已删除邮件文件夹Move to the Deleted Items folder
这是删除项目的最不永久方法。This is the least permanent way to delete items.

这类似于在你的办公桌的回收站中放置一张纸。This is like putting a piece of paper in the recycle bin by your desk. 如果需要,你可以轻松地获取它。You can easily grab it if you need it again.

您可以使用任何实现 "移动到已删除邮件" 文件夹选项的删除操作来执行此操作。You can use any deletion operation that implements the move to the Deleted Items folder option to perform this action.

您还可以使用MoveItem 操作move ())或MoveFolder 操作文件夹. move ())将项目或文件夹移动到 "已删除邮件" 文件夹中。You can also use the MoveItem operation ( Item.Move()) or the MoveFolder operation ( Folder.Move()) to move an item or folder to the Deleted Items folder.
软删除Soft delete
将项目移动到转储程序中的 "删除" 文件夹。The item is moved to the Deletions folder in the dumpster.

这类似于将回收站清空到 curbside 容器中。This is like emptying your recycle bin into your curbside container. 如果需要,仍可以访问该项目,这只是一个更难的方法。You can still access the item if you need to, it's just a little harder.

有关转储程序(也称为 "可恢复的项目" 文件夹)和方案(如电子数据展示或诉讼保留)的详细信息,请参阅 TechNet 上的 "可恢复的项目" 文件夹For more about the dumpster (also called the Recoverable Items folder) and scenarios such as eDiscovery or litigation holds, see Recoverable Items Folder on TechNet.

对于以 Exchange 2007 为目标的应用程序,不建议使用软删除。Soft deletions aren't recommended for applications that target Exchange 2007. 在 Exchange 2007 中,通过在项目上设置一个位来指示将其在未指定时间移动到转储程序,可以处理软删除。In Exchange 2007, soft deletions are handled by setting a bit on the item to indicate that it will be moved to the dumpster at an unspecified time.

"软删除" traversals 或搜索通过FindItem 操作软删除的项目不受 exchange Online、exchange Online 作为 Office 365 的一部分,以及从 exchange 2010 开始的 exchange 版本。Soft delete traversals, or searches of items that have been soft deleted via the FindItem operation, are not supported in Exchange Online, Exchange Online as part of Office 365, and versions of Exchange starting with Exchange 2010.

注意:不能软删除文件夹。NOTE: Folders cannot be soft deleted.
硬删除Hard delete
项目或文件夹将被永久删除。The item or folder is permanently deleted.

硬删除的项目放置在转储程序的 "清除" 文件夹中。Hard-deleted items are placed in the Purges folder of the dumpster. 这类似于回收卡车清空 curbside 回收容器的情况。This is like when the recycling truck empties your curbside recycle container. 无法从 Outlook 或 Outlook Web App 等电子邮件客户端访问这些项目,除非邮箱中设置了保留,否则会在设定的一段时间后永久删除这些项目。The items cannot be accessed from an email client like Outlook or Outlook Web App, and, unless there is a hold set on the mailbox, the items will be permanently deleted after a set period of time.

有关项目保留的详细信息,请参阅配置已删除邮件的保留和可恢复的项目配额一文。You can read more about item retention in the article Configure Deleted Item Retention and Recoverable Items Quotas.

注意:文件夹在硬删除时不会放置在 "清除" 文件夹中。NOTE: Folders are not placed in the Purges folder when they are hard deleted. 硬删除的文件夹将从邮箱中删除。Hard-deleted folders are removed from the mailbox.

移动到 "已删除邮件" 文件夹和硬删除选项都是事务性的,这意味着在 web 服务调用完成时,项目已移动到 "已删除邮件" 文件夹或转储程序。The move to the Deleted Items folder and the hard delete options are transactional, which means that by the time the web service call finishes, the item has been moved to the Deleted Items folder or the dumpster.

为了帮助您更好地了解用于存储已删除项目的文件夹生态系统,下图显示了可以包含已删除项目的文件夹的层次结构。To help you better understand the ecosystem of folders that are used to store deleted items, the following figure shows the hierarchy of folders that can contain deleted items. 文件夹名称在DistinguishedFolderIdNameType架构类型中显示,或在 EWS 托管 API 中的WellKnownFolderName枚举中显示。The folder names are as they appear in the DistinguishedFolderIdNameType schema type, or the WellKnownFolderName enumeration in the EWS Managed API.

图3。包含已删除项目的文件夹的层次结构Figure 3. Hierarchy of folders that contain deleted items

此图显示文件夹的文件夹层次结构,其中可包含主邮箱和存档邮箱中的已删除邮件。图像中的每个文件夹由其可分辨的文件夹名称表示。

表2:包含已删除项目的文件夹Table 2: Folders that contain deleted items

文件夹名Folder name 引入版本Introduced in 说明Description
deleteditemsdeleteditems
Exchange 2007Exchange 2007
默认的 "已删除邮件" 文件夹。The default Deleted Items folder. 项目将保留在此文件夹中,直到它们软或硬删除,或者超过保留期。Items remain in this folder until they are soft- or hard-deleted or until a retention period has been exceeded. 然后,将它们移动到转储程序中的文件夹。Then they are moved to a folder in the dumpster. 已删除的文件夹放在 "已删除邮件" 文件夹中,当它们是软或硬删除的,它们将从邮箱中永久删除且不可恢复。Deleted folders are placed in the Deleted Items folder, and when they are soft- or hard-deleted, they are permanently removed from the mailbox and are not recoverable.
recoverableitemsrootrecoverableitemsroot
Exchange 2010Exchange 2010
转储程序或 "可恢复的项目" 文件夹的根。The root of the dumpster, or the Recoverable Items folder. 转储程序访问在 Exchange 2010 中是在 EWS 中实现的。Dumpster access was implemented in EWS in Exchange 2010. 此文件夹的显示名称是 "可恢复的项目"。The display name for this folder is "Recoverable Items".
recoverableitemsdeletionsrecoverableitemsdeletions
Exchange 2010Exchange 2010
邮箱的主转储程序文件夹。The main dumpster folder for a mailbox. 从 "已删除邮件" 文件夹中的保留策略移动的软删除项目和项目放置在此文件夹中。Soft-deleted items and items moved from the Deleted Items folder by a retention policy are placed in this folder. 此文件夹的显示名称为 "删除"。The display name for this folder is "Deletions".
recoverableitemsversionsrecoverableitemsversions
Exchange 2010Exchange 2010
项目的较旧版本的存储位置。Where older versions of an item are stored. 项目的旧版本在更新项目时创建。Old versions of an item are created when an item is updated. 草稿项目版本不会保存到此文件夹中。Draft item versions are not saved to this folder. 此文件夹的显示名称为 "版本"。The display name of this folder is "Versions".
recoverableitemspurgesrecoverableitemspurges
Exchange 2010Exchange 2010
存储从 "删除" 文件夹中删除的项目的位置。Where items that are removed from the Deletions folder are stored. 所有存储硬删除项目都将移到此文件夹。All store hard-deleted items are moved to this folder. 此文件夹的显示名称为 "清除"。The display name for this folder is "Purges".
archiveddeletedtitemsarchiveddeletedtitems
Exchange 2010Exchange 2010
存档邮箱的默认 "已删除邮件" 文件夹。The default Deleted Items folder for an archive mailbox.
archiverecoverablesitemsrootarchiverecoverablesitemsroot
Exchange 2010Exchange 2010
存档邮箱的根转储程序文件夹。The root dumpster folder for an archive mailbox. 软删除的已存档项目将移至此文件夹中的子文件夹。Archived items that are soft-deleted are moved to a subfolder in this folder.
archiverecoverableitemsdeletionsarchiverecoverableitemsdeletions
Exchange 2010Exchange 2010
存档邮箱的主转储程序文件夹。The main dumpster folder for an archive mailbox. 移动到转储程序的存档项目放置在此处。Archived items moved to the dumpster are placed here.
archiverecoverableitemsversionsarchiverecoverableitemsversions
Exchange 2010Exchange 2010
存档项目的较旧版本的存储位置。Where older versions of archived items are stored.
archiverecoverableitemspurgesarchiverecoverableitemspurges
Exchange 2010Exchange 2010
从转储程序中的 "存档删除" 文件夹中硬删除的项目存储。Where items that are hard-deleted from the archive Deletions folder in the dumpster are stored. 所有存储硬删除的存档项目都将移到此文件夹。All store hard-deleted archived items are moved to this folder.

如何删除项目?How do I delete items?

使用下列命令之一来指示是将项目移动到 "已删除邮件" 文件夹,还是执行软删除或硬删除:Use one of the following to indicate whether to move an item to the Deleted Items folder or perform a soft delete or a hard delete:

  • DisposalType简单类型(如果您使用 EWS 访问 Exchange)。The DisposalType simple type, if you use EWS to access Exchange.

  • DeleteMode 枚举(如果使用 EWS 托管 API)。The DeleteMode enumeration, if you use the EWS Managed API.

您可以使用许多不同的 EWS 操作或 EWS 托管 API 方法从邮箱中删除项目和文件夹。You can use a number of different EWS operations or EWS Managed API methods to delete items and folders from a mailbox.

表3:用于删除项目的 EWS 操作和 EWS 托管的 API 方法Table 3: EWS operations and EWS Managed API methods for deleting items

EWS 操作EWS operation EWS 托管的 API 方法EWS Managed API method 引入版本Introduced in 功能What it does
DeleteFolder 操作DeleteFolder operation
文件夹. Delete 方法Folder.Delete method
Exchange 2007Exchange 2007
从邮箱中删除文件夹。Deletes folders from a mailbox. 使用 EWS,可以批量删除文件夹。With EWS, you can batch delete folders. 使用 EWS 托管 API,您只能删除每个调用的单个文件夹。With the EWS Managed API, you can only delete a single folder per call.
DeleteItem 操作DeleteItem operation
Item. Delete 方法Item.Delete method

ExchangeService 方法ExchangeService.DeleteItems method
Exchange 2007Exchange 2007
删除邮箱中的项目。Deletes items from a mailbox.
EmptyFolder 操作EmptyFolder operation
Folder. 空方法Folder.Empty method
Exchange 2010Exchange 2010
删除文件夹中的所有项目,也可以选择删除文件夹中的所有子文件夹。Deletes all the items in a folder, and, optionally, deletes all subfolders in a folder.
ApplyConversationAction 操作ApplyConversationAction operation
EnableAlwaysDeleteItems 方法Conversation.EnableAlwaysDeleteItems method

DeleteItems 方法Conversation.DeleteItems method
Exchange 2010Exchange 2010
对对话中的电子邮件设置删除处理操作,以便将其删除。Sets a delete processing action on email messages in a conversation so that they are deleted.
DeleteUserConfiguration 操作DeleteUserConfiguration operation
UserConfiguration 方法UserConfiguration.Delete method
Exchange 2010Exchange 2010
删除一个与文件夹相关联的项目,并将其移动到转储程序。Deletes a folder associated item and moves it to the dumpster.
CreateItem 操作CreateItem operation
约会. Accept 方法Appointment.Accept method

AcceptTentatively 方法Appointment.AcceptTentatively method

CancelMeeting 方法Appointment.CancelMeeting method

约会:拒绝Appointment.Decline

MeetingRequest 方法MeetingRequest.Accept method

MeetingRequest 方法MeetingRequest.AcceptTentatively method

MeetingRequest 方法MeetingRequest.Decline method
Exchange 2007Exchange 2007
无论何时发送会议请求的响应或在约会上设置响应,都会将项目间接移动到 "已删除邮件" 文件夹。Indirectly moves an item to the Deleted Items folder whenever a response to a meeting request is sent or the response is set on the appointment.

此操作上未设置删除类型。The deletion type is not set on this operation. 当服务成功处理响应对象时,会将会议邮件移至 "已删除邮件" 文件夹。The meeting messages are moved to the Deleted Items folder when a response object is successfully processed by the service.

您还可以使用收件箱规则将项目移动到 "已删除邮件" 文件夹。You can also move items to the Deleted Items folder by using Inbox rules. 例如,您可以创建具有 "删除" 操作的规则For example, you can create rules that have a delete action.

有关删除项目的几点注意事项:Some points to note about deleting items:

  • 删除定期项目的事件不会触发移动到 "已删除邮件" 文件夹或转储程序。Deleting an occurrence of a recurring item does not trigger a move to the Deleted Items folder or the dumpster. 这将导致对定期系列定期主项目的更新。This results in an update to the recurring master item of the recurring series.

  • 您不能从邮箱中删除默认文件夹。You cannot delete default folders from the mailbox.

  • 避免删除会议或会议邮件,如会议请求和会议更新。Avoid deleting meetings or meeting messages, such as meeting requests and or meeting updates. 而是使用 response 对象来响应这些项目。Instead, respond to these items by using response objects. 这样一来,将更新关联的日历项目以反映响应者或组织者的操作。This way, the associated calendar items are updated to reflect the responder's or organizer's actions.

  • 将项目移动到 "已删除邮件" 或 "删除内容" 文件夹中时,不会更新项目的更改密钥。An item's change key is not updated when the item is moved to the Deleted Items or Deletions folder.

  • 如果对项目执行硬删除,然后调用SyncFolderHierarchy 操作SYNCFOLDERHIERARCHY EWS 托管 API 方法,或SyncFolderItems 操作SyncFolderItems方法,则将返回 "删除更改" 条目。If you perform a hard delete on an item and then call a SyncFolderHierarchy operation or SyncFolderHierarchy EWS Managed API method, or a SyncFolderItems operation or SyncFolderItems method, a Delete change entry will be returned. 如果将项目移动到 "已删除邮件" 文件夹中,则会返回 "更新更改" 条目。If you move an item to the Deleted Items folder, an Update change entry is returned. 这是因为项目或文件夹将具有新的ParentFolderId属性值。This is because the item or folder will have a new ParentFolderId property value. 若要了解同步已删除项目属于方案的一部分,请阅读有关同步的详细信息Read more about synchronization if synchronizing deleted items is part of your scenario.

查找有关删除项目的详细信息Find out more about deleting items

另请参阅See also