次の方法で共有


Conversation オブジェクト (Outlook)

1 つ以上のフォルダーやストアに保存されている 1 つ以上のアイテムが含まれているスレッドを表します。

注釈

スレッド オブジェクトは、抽象、集約されたオブジェクトです。 会話には、さまざまな種類のアイテムを含めることができます、ですが、 会話 オブジェクトでは、特定の基になる MAPI IMessage オブジェクトに対応していません。

スレッドは 1 つ以上のフォルダーやストア内の 1 つ以上のアイテムを表します。 スレッド内のアイテムを [ 削除済みアイテム] フォルダーに移動し、その後で GetChildren メソッド、 GetRootItems メソッド、または GetTable メソッドを使用してスレッドを列挙した場合、返されるオブジェクトにそのアイテムは含まれません。

既存の対話の スレッド オブジェクトを取得するには、アイテムの GetConversation メソッドを使用します。

SetAlwaysAssignCategoriesSetAlwaysDelete、または SetAlwaysMoveToFolder メソッドを呼び出すことで、会話内のアイテムに適用できるアクションがあります。 これらの各アクションは、 メソッドが呼び出されると、会話内のすべての項目に自動的に適用されます。アクションが会話に適用される限り、アクションは会話内の将来のアイテムにも適用されます。 Conversation オブジェクトに明示的な保存メソッドはありません。

さらに、スレッド内のアイテムにアクションを適用すると、対応するイベントが発生します。 たとえば、Items オブジェクトの ItemChange イベントは SetAlwaysAssignCategories を呼び出すと発生し、Folder オブジェクトの BeforeItemMove イベントは SetAlwaysMoveToFolder を呼び出すときに発生します。

次のマネージ コードは C# で作成されています。 コンポーネント オブジェクト モデル (COM) に呼び出す必要がある .NET Framework マネージ コード サンプルを実行するには、マネージ インターフェイスを定義し、オブジェクト モデル タイプ ライブラリの COM オブジェクトにマップする相互運用機能アセンブリを使用する必要があります。 Outlook の場合、Visual Studio および Outlook プライマリ相互運用機能アセンブリ (PIA) を使用できます。 Outlook 2013 用のマネージ コード サンプルを実行する前に、Outlook 2013 PIA をインストールしており、Visual Studio で Microsoft Outlook 15.0 オブジェクト ライブラリ コンポーネントへの参照を追加していることを確認してください。 Outlook アドインのクラスで次のコードを ThisAddIn 使用する必要があります (Office Developer Tools for Visual Studio を使用)。 コードの Application オブジェクトは で提供された、信頼済み Outlook ThisAddIn.Globals オブジェクトである必要があります。 Outlook PIA を使用してマネージド Outlook ソリューションを開発する方法の詳細については、MSDN の 「Outlook プライマリ相互運用機能アセンブリ リファレンスへようこそ」を参照 してください。

次のコード例では、エクスプ ローラー ウィンドウで選択した項目は、メール アイテムであると仮定します。 コード例では、会話を選択したメール アイテムに関連付けられているし、その会話は、アイテムの件名を表示するのには、各項目の列挙を取得します。 メソッドは DemoConversation 、選択したメール アイテムの GetConversation メソッドを呼び出して、関連付けられた Conversation オブジェクトを取得します。 DemoConversationは、それぞれ テーブル オブジェクトと、 SimpleItems コレクションを取得する スレッド オブジェクトの GetTableGetRootItems メソッドを呼び出します。 DemoConversationでは、列挙し、その会話の各アイテムの件名を表示する繰り返しメソッド EnumerateConversationを呼び出します。

void DemoConversation() 
{ 
 object selectedItem = 
 Application.ActiveExplorer().Selection[1]; 
 // This example uses only 
 // MailItem. Other item types such as 
 // MeetingItem and PostItem can participate 
 // in the conversation. 
 if (selectedItem is Outlook.MailItem) 
 { 
 // Cast selectedItem to MailItem. 
 Outlook.MailItem mailItem = 
 selectedItem as Outlook.MailItem; 
 // Determine the store of the mail item. 
 Outlook.Folder folder = mailItem.Parent 
 as Outlook.Folder; 
 Outlook.Store store = folder.Store; 
 if (store.IsConversationEnabled == true) 
 { 
 // Obtain a Conversation object. 
 Outlook.Conversation conv = 
 mailItem.GetConversation(); 
 // Check for null Conversation. 
 if (conv != null) 
 { 
 // Obtain Table that contains rows 
 // for each item in the conversation. 
 Outlook.Table table = conv.GetTable(); 
 Debug.WriteLine("Conversation Items Count: " + 
 table.GetRowCount().ToString()); 
 Debug.WriteLine("Conversation Items from Table:"); 
 while (!table.EndOfTable) 
 { 
 Outlook.Row nextRow = table.GetNextRow(); 
 Debug.WriteLine(nextRow["Subject"] 
 + " Modified: " 
 + nextRow["LastModificationTime"]); 
 } 
 Debug.WriteLine("Conversation Items from Root:"); 
 // Obtain root items and enumerate the conversation. 
 Outlook.SimpleItems simpleItems 
 = conv.GetRootItems(); 
 foreach (object item in simpleItems) 
 { 
 // In this example, only enumerate MailItem type. 
 // Other types such as PostItem or MeetingItem 
 // can appear in the conversation. 
 if (item is Outlook.MailItem) 
 { 
 Outlook.MailItem mail = item 
 as Outlook.MailItem; 
 Outlook.Folder inFolder = 
 mail.Parent as Outlook.Folder; 
 string msg = mail.Subject 
 + " in folder " + inFolder.Name; 
 Debug.WriteLine(msg); 
 } 
 // Call EnumerateConversation 
 // to access child nodes of root items. 
 EnumerateConversation(item, conv); 
 } 
 } 
 } 
 } 
} 
 
 
void EnumerateConversation(object item, 
 Outlook.Conversation conversation) 
{ 
 Outlook.SimpleItems items = 
 conversation.GetChildren(item); 
 if (items.Count > 0) 
 { 
 foreach (object myItem in items) 
 { 
 // In this example, only enumerate MailItem type. 
 // Other types such as PostItem or MeetingItem 
 // can appear in the conversation. 
 if (myItem is Outlook.MailItem) 
 { 
 Outlook.MailItem mailItem = 
 myItem as Outlook.MailItem; 
 Outlook.Folder inFolder = 
 mailItem.Parent as Outlook.Folder; 
 string msg = mailItem.Subject 
 + " in folder " + inFolder.Name; 
 Debug.WriteLine(msg); 
 } 
 // Continue recursion. 
 EnumerateConversation(myItem, conversation); 
 } 
 } 
} 
 

メソッド

名前
ClearAlwaysAssignCategories
GetAlwaysAssignCategories
GetAlwaysDelete
GetAlwaysMoveToFolder
GetChildren
GetParent
GetRootItems
GetTable
MarkAsRead
MarkAsUnread
SetAlwaysAssignCategories
SetAlwaysDelete
SetAlwaysMoveToFolder
StopAlwaysDelete
StopAlwaysMoveToFolder

プロパティ

名前
アプリケーション
クラス
ConversationID
Parent
Session

関連項目

Outlook オブジェクト モデル参照会話オブジェクト メンバー

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。