Mengelola Item Percakapan di Server Exchange
Aspose.Email untuk .NET dapat digunakan untuk mengelola item percakapan di Server Exchange dengan EWSClient kelas. Kelas ini menggunakan Exchange Web Services, yang hanya tersedia di Exchange Server 2007 dan rilis selanjutnya. Artikel ini menunjukkan cara temukan, salin, pindahkan dan hapus item percakapan pada Exchange Server 2010. Microsoft Exchange Server 2010 Service Pack 1 diperlukan untuk semua fitur yang termasuk dalam bagian ini.
Temukan Percakapan
Untuk mendapatkan informasi percakapan dari folder tertentu di Exchange Server:
- Terhubung ke Server Exchange menggunakan IEWSClient antarmuka.
- Panggil IEWSClient.FindConversations() metode untuk menemukan semua item percakapan dari sebuah folder.
- Tampilkan properti item percakapan seperti ID, topik percakapan, dan status flag.
Potongan kode berikut menunjukkan cara menemukan percakapan.
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
Console.WriteLine("Connected to Exchange 2010");
// Find Conversation Items in the Inbox folder
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);
// Show all conversations
foreach (ExchangeConversation conversation in conversations)
{
// Display conversation properties like Id and Topic
Console.WriteLine("Topic: " + conversation.ConversationTopic);
Console.WriteLine("Flag Status: " + conversation.FlagStatus.ToString());
Console.WriteLine();
}
Salin Percakapan
Untuk menyalin percakapan dari satu folder ke folder lain:
- Terhubung ke Server Exchange menggunakan IEWSClient antarmuka.
- Panggil IEWSClient.CopyConversationItems() metode untuk menyalin item percakapan dari folder sumber ke folder tujuan.
Potongan kode berikut menunjukkan cara menyalin percakapan.
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
Console.WriteLine("Connected to Exchange 2010");
// Find those Conversation Items in the Inbox folder which we want to copy
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);
foreach (ExchangeConversation conversation in conversations)
{
Console.WriteLine("Topic: " + conversation.ConversationTopic);
// Copy the conversation item based on some condition
if (conversation.ConversationTopic.Contains("test email") == true)
{
client.CopyConversationItems(conversation.ConversationId, client.MailboxInfo.DeletedItemsUri);
Console.WriteLine("Copied the conversation item to another folder");
}
}
Pindahkan Percakapan
Untuk memindahkan percakapan dari satu folder ke folder lain:
- Terhubung ke Server Exchange menggunakan IEWSClient antarmuka.
- Panggil IEWsClient.MoveConversationItems() metode untuk memindahkan percakapan dari folder sumber ke folder tujuan.
Potongan kode berikut menunjukkan cara memindahkan percakapan.
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
Console.WriteLine("Connected to Exchange 2010");
// Find those Conversation Items in the Inbox folder which we want to move
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);
foreach (ExchangeConversation conversation in conversations)
{
Console.WriteLine("Topic: " + conversation.ConversationTopic);
// Move the conversation item based on some condition
if (conversation.ConversationTopic.Contains("test email") == true)
{
client.MoveConversationItems(conversation.ConversationId, client.MailboxInfo.DeletedItemsUri);
Console.WriteLine("Moved the conversation item to another folder");
}
}
Hapus Percakapan
Untuk menghapus percakapan dari sebuah folder:
- Terhubung ke Server Exchange menggunakan IEWSClient antarmuka.
- Panggil IEWSClient.DeleteConversationItems() metode untuk menghapus item percakapan dari folder sumber.
Potongan kode berikut menunjukkan cara menghapus percakapan.
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
Console.WriteLine("Connected to Exchange 2010");
// Find those Conversation Items in the Inbox folder which we want to delete
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);
foreach (ExchangeConversation conversation in conversations)
{
Console.WriteLine("Topic: " + conversation.ConversationTopic);
// Delete the conversation item based on some condition
if (conversation.ConversationTopic.Contains("test email") == true)
{
client.DeleteConversationItems(conversation.ConversationId);
Console.WriteLine("Deleted the conversation item");
}
}