Zarządzanie elementami konwersacji

Aspose.Email dla Javy może być użyty do zarządzania elementami konwersacji na serwerze Exchange przy pomocy EWSClient klasa. Ta klasa korzysta z Exchange Web Services, które są dostępne tylko w Exchange Server 2007 i późniejszych wersjach. Ten artykuł pokazuje, jak znajdź, kopiuj, przenieś i usuń elementy konwersacji na Exchange Server 2010. Microsoft Exchange Server 2010 Service Pack 1 jest wymagany dla wszystkich funkcji zawartych w tej sekcji.

Znajdowanie konwersacji

Aby uzyskać informacje o konwersacji z konkretnego folderu na serwerze Exchange:

  1. Połącz się z serwerem Exchange używając klasy IEWSClient.
  2. Wywołaj metodę IEWSClient.findConversations(), aby znaleźć wszystkie elementy konwersacji z folderu.
  3. Wyświetl właściwości elementu konwersacji, takie jak ID, temat konwersacji i status flagi.

Poniższy fragment kodu pokazuje, jak znaleźć konwersacje.

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();
}

Kopiowanie konwersacji

Aby skopiować konwersacje z jednego folderu do drugiego:

  1. Połącz się z serwerem Exchange używając klasy IEWSClient.
  2. Wywołaj metodę IEWSClient.copyConversationItems(), aby skopiować element konwersacji z folderu źródłowego do docelowego.

Poniższy fragment kodu pokazuje, jak kopiować konwersacje.

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");
    }
}

Przenoszenie konwersacji

Aby przenieść konwersacje z jednego folderu do drugiego:

  1. Połącz się z serwerem Exchange używając klasy IEWSClient.
  2. Wywołaj metodę IEWSClient.moveConversationItems(), aby przenieść konwersację z folderu źródłowego do docelowego.

Poniższy fragment kodu pokazuje, jak przenosić konwersacje.

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");
    }
}

Usuwanie konwersacji

Aby usunąć konwersacje z folderu:

  1. Połącz się z serwerem Exchange używając klasy IEWSClient.
  2. Wywołaj metodę IEWSClient.deleteConversationItems(), aby usunąć element konwersacji z folderu źródłowego.

Poniższy fragment kodu pokazuje, jak usunąć konwersacje.

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");
    }
}