以会话方式管理 Outlook 项目Managing Outlook Items as Conversations

在 Microsoft Outlook 中,对话对共享同一主题并属于同一线程的邮件进行分组。In Microsoft Outlook, a conversation groups messages that share the same subject and belong to the same thread. 在 Outlook 用户界面中,您可以在 "会话" 视图中展开对话,以提供邮件之间的可视关系,包括来自其他文件夹的任何响应和相关邮件。In the Outlook user interface, you can expand a conversation in Conversation view to provide a visual relationship between messages, including any responses and related messages from other folders. 会话还可以包括分支,如在邮件获得两个或更多个彼此独立增长的响应和讨论时。A conversation can also include branches, such as when a message gets two or more responses and discussions grow independently from each. 由于 Outlook,会话视图在文件夹和存储区中关联同一个对话中的所有项目。Since Outlook, Conversation view relates all items in the same conversation across folders and stores.

从编程角度来看,同一对话中的项目可以是属于一个或多个项目类型的异类。From the programmatic perspective, items in the same conversation can be heterogeneous, belonging to one or more item types. 例如,对话可以包含**MailItem** 和**TaskItem** 对象。For example, a conversation can contain MailItem and TaskItem objects. 在 Outlook 之前,对属于同一对话的项目的支持限制为ConversationIndexConversationTopic属性(除**NoteItem** 对象之外的所有项目类型)。Before Outlook, support for items that belong to the same conversation was limited to the ConversationIndex and ConversationTopic properties (for all item types except the NoteItem object). 清除ConversationIndex限制为**MailItemPostItemSharingItem** 对象。Clearing the ConversationIndex was limited to the MailItem, PostItem, and SharingItem objects. 由于 Outlook,Outlook 支持**对话** 对象,该对象通过使用会话对象上的ConversationID属性以及会话的每个项目,在整个文件夹和存储区中关联同一对话中的所有项目。Since Outlook, Outlook supports the Conversation object, which relates all items in the same conversation across folders and across stores by using the ConversationID property on the Conversation object as well as on each item of the conversation. Outlook 为大多数项目类型提供 GetConversation 方法,以使您基于该项目获取 Conversation 对象。Outlook provides a GetConversation method for most item types to enable you to obtain a Conversation object based on the item.

对于 POP、IMAP、PST 或 Microsoft Exchange Server (至少是 Microsoft Exchange Server 2010,或者 Microsoft Exchange Server 2007,如果 Outlook 在缓存模式下运行)中的存储支持对话视图。Conversation view is supported by stores that are POP, IMAP, PST, or Microsoft Exchange Server (at least Microsoft Exchange Server 2010, or Microsoft Exchange Server 2007 if Outlook is running in cached mode). 您可以调用**store** 对象的**IsConversationEnabled** 属性,以验证存储是否支持会话视图。You can call the IsConversationEnabled property of the Store object to verify whether the store supports Conversation view. 只有在项目所驻留的存储支持对话视图时,才能调用GetConversation方法,以基于对话中的项目获取对话对象。You can call the GetConversation method to get a Conversation object based on an item in the conversation only if the store in which the item resides supports Conversation view.

若要导航会话层次结构,您可以调用会话对象的**GetChildrenGetParentGetRootItems** 方法。To navigate a conversation hierarchy, you can call the GetChildren, GetParent, and GetRootItems methods of the Conversation object. SimpleItems 集合存在,以提供对会话项目的轻松访问。The SimpleItems collection exists to provide easy access to items of the conversation. SimpleItems 集合中项目的顺序与会话中项目的顺序相同。The order of items in the SimpleItems collection is the same as the order of items in the conversation. 按每个项目的 MAPI PidTagCreationTime属性以升序顺序对集合进行排序。The collection is ordered by the MAPI PidTagCreationTime property of each item in ascending order. 若要枚举对话中的项目,可以使用**Table** 对象。To enumerate items in a conversation, you can use the Table object. 表的行表示会话的项目,并且可以自定义的表的列表示每个项目的属性。The rows of the table represent items of the conversation, and the columns of the table, which you can customize, represent properties for each item. 若要使用 Table 对象获取会话项目,请使用以下过程:To obtain conversation items by using a Table object, use the following procedure:

  1. 获取会话中任何项目的对象。Obtain the object of any item in the conversation.

  2. 若要验证存储区是否支持会话视图,请使用代表项目所驻留存储区的 Store 对象的 IsConversationEnabled 属性。To verify that the store supports Conversation view, use the IsConversationEnabled property of the Store object that represents the store in which the item resides. 只有当项目驻留在支持会话视图的存储区中时,才可以基于该项目获取 Conversation 对象。You can obtain a Conversation object based on an item only if the item resides in a store that supports Conversation view.

  3. 如果存储区支持会话视图,请调用该项目的 GetConversation 方法来获取 Conversation 对象。If the store supports Conversation view, call the GetConversation method of that item to get the Conversation object.

  4. 调用该会话对象的**GetTable** 方法以获取一个Call the GetTable method of that Conversation object to get a Table.

  5. 现在,可以使用 Table 对象支持的方法来枚举代表会话项目的行,使用默认列访问默认项目属性(或者自定义列以访问项目的其他属性)。You can now use methods that the Table object supports to enumerate rows that represent conversation items, and use the default columns to access default item properties (or customize columns to access other properties of the items).

您可以使用**SetAlwaysDelete** 和**SetAlwaysMoveToFolder** 方法始终将现有会话项目以及到达特定对话的后续项目移到 "已删除邮件" 文件夹或其他文件夹。You can use the SetAlwaysDelete and SetAlwaysMoveToFolder methods to always move existing conversation items, and future items that arrive in a specific conversation, to the Deleted Items folder or another folder. 在项目驻留的特定存储区中支持项目的移动,除非该存储区是一个非送达存储区,例如 PST 存储区。The moving of items is supported in the specific store where the item resides, unless the store is a non-delivery store such as a PST store. 您可以使用**GetAlwaysDelete** 和**GetAlwaysMoveToFolder** 方法获取这些文件夹,并使用**StopAlwaysDelete** 和**StopAlwaysMoveToFolder** 方法来停止将现有和将来会话项目移到此类文件夹中。You can use the GetAlwaysDelete and GetAlwaysMoveToFolder methods to get these folders, and the StopAlwaysDelete and StopAlwaysMoveToFolder methods to stop moving existing and future conversation items to such folders. 此外,您可以对会话的所有现有和将来项目应用操作。In addition, you can apply actions to all existing and future items of a conversation.

另请参阅See also

如何︰ 获取和枚举选的对话How to: Obtain and Enumerate Selected Conversations

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.