会話項目の管理

Aspose.Email for Java は、Exchange Server 上の会話項目を管理するために使用できます。 EWSClient クラス。このクラスは Exchange Web Services を使用しますが、これは Exchange Server 2007 以降でのみ利用可能です。本記事では、方法を示します。 検索, コピー, 移動 および 削除 Exchange Server 2010 の会話項目です。このセクションのすべての機能には Microsoft Exchange Server 2010 Service Pack 1 が必要です。

会話の検索

Exchange Server の特定フォルダーから会話情報を取得するには:

  1. IEWSClient クラスを使用して Exchange Server に接続します。
  2. フォルダーからすべての会話項目を検索するには、IEWSClient.findConversations() メソッドを呼び出します。
  3. ID、会話トピック、フラッグステータスなどの会話項目プロパティを表示します。

以下のコードスニペットは、会話を検索する方法を示しています。

IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials);
System.out.println("Connected to Exchange 2010");

// Find Conversation Items in the Inbox folder
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri());
// Show all conversations
for (ExchangeConversation conversation : conversations) {
    // Display conversation properties like Id and Topic
    System.out.println("Topic: " + conversation.getConversationTopic());
    System.out.println("Flag Status: " + conversation.getFlagStatus());
    System.out.println();
}

会話のコピー

会話をあるフォルダーから別のフォルダーへコピーするには:

  1. IEWSClient クラスを使用して Exchange Server に接続します。
  2. ソースフォルダーから宛先フォルダーへ会話項目をコピーするには、IEWSClient.copyConversationItems() メソッドを呼び出します。

以下のコードスニペットは、会話をコピーする方法を示しています。

IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials);
System.out.println("Connected to Exchange 2010");

// Find those Conversation Items in the Inbox folder which we want to copy
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri());
for (ExchangeConversation conversation : conversations) {
    System.out.println("Topic: " + conversation.getConversationTopic());
    // Copy the conversation item based on some condition
    if (conversation.getConversationTopic().contains("test email")) {
        client.copyConversationItems(conversation.getConversationId(), client.getMailboxInfo().getDeletedItemsUri());
        System.out.println("Copied the conversation item to another folder");
    }
}

会話の移動

会話をあるフォルダーから別のフォルダーへ移動するには:

  1. IEWSClient クラスを使用して Exchange Server に接続します。
  2. ソースフォルダーから宛先フォルダーへ会話を移動するには、IEWSClient.moveConversationItems() メソッドを呼び出します。

以下のコードスニペットは、会話を移動する方法を示しています。

IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials);
System.out.println("Connected to Exchange 2010");

// Find those Conversation Items in the Inbox folder which we want to move
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri());

for (ExchangeConversation conversation : conversations) {
    System.out.println("Topic: " + conversation.getConversationTopic());
    // Move the conversation item based on some condition
    if (conversation.getConversationTopic().contains("test email") == true) {
        client.moveConversationItems(conversation.getConversationId(), client.getMailboxInfo().getDeletedItemsUri());
        System.out.println("Moved the conversation item to another folder");
    }
}

会話の削除

フォルダーから会話を削除するには:

  1. IEWSClient クラスを使用して Exchange Server に接続します。
  2. ソースフォルダーから会話項目を削除するには、IEWSClient.deleteConversationItems() メソッドを呼び出します。

以下のコードスニペットは、会話を削除する方法を示しています。

IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials);
System.out.println("Connected to Exchange 2010");

// Find those Conversation Items in the Inbox folder which we want to delete
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri());
for (ExchangeConversation conversation : conversations) {
    System.out.println("Topic: " + conversation.getConversationTopic());
    // Delete the conversation item based on some condition
    if (conversation.getConversationTopic().contains("test email") == true) {
        client.deleteConversationItems(conversation.getConversationId());
        System.out.println("Deleted the conversation item");
    }
}