Read the complete article on how to find, copy, move, and delete conversations from Microsoft Exchange Server in Java: https://blog.aspose.com/2022/02/28/work-with-conversations-on-ms-exchange-server-in-java/
Last active
March 31, 2022 07:42
-
-
Save aspose-com-gists/6dc20fbc731592afcdc8e14707120f21 to your computer and use it in GitHub Desktop.
Find, copy, move, and delete conversations from Microsoft Exchange Server in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set mailbox URI, username, password, domain information | |
String mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
String username = "test.exchange"; | |
String password = "pwd"; | |
String domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials); | |
System.out.println("Connected to Exchange"); | |
// Find conversation items in the inbox folder | |
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri()); | |
// Show all conversations | |
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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set mailbox URI, username, password, domain information | |
String mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
String username = "test.exchange"; | |
String password = "pwd"; | |
String domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials); | |
System.out.println("Connected to Exchange"); | |
// Find conversation items in the inbox folder | |
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri()); | |
// Show all conversations | |
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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set mailbox URI, username, password, domain information | |
String mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
String username = "test.exchange"; | |
String password = "pwd"; | |
String domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials); | |
System.out.println("Connected to Exchange"); | |
// 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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set mailbox URI, username, password, domain information | |
String mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
String username = "test.exchange"; | |
String password = "pwd"; | |
String domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials); | |
System.out.println("Connected to Exchange"); | |
// Find conversation items in the inbox folder | |
ExchangeConversation[] conversations = client.findConversations(client.getMailboxInfo().getInboxUri()); | |
// Show all conversations | |
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"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment