การจัดการรายการสนทนาบน Exchange Server

Aspose.Email for .NET สามารถใช้เพื่อจัดการรายการสนทนาบน Exchange Server ด้วย EWSClient คลาส นี้ใช้ Exchange Web Services ซึ่งมีเฉพาะใน Exchange Server 2007 ขึ้นไป บทความนี้แสดงวิธีการ ค้นหา, คัดลอก, ย้าย และ ลบ รายการสนทนาบน Exchange Server 2010 ต้องใช้ Microsoft Exchange Server 2010 Service Pack 1 สำหรับคุณลักษณะทั้งหมดที่รวมอยู่ในส่วนนี้.

ค้นหาการสนทนา

เพื่อรับข้อมูลการสนทนาจากโฟลเดอร์เฉพาะบน Exchange Server:

  1. เชื่อมต่อกับ Exchange Server ด้วยการใช้ IEWSClient อินเทอร์เฟซ
  2. เรียกใช้ IEWsClient.FindConversations() เมธอดเพื่อค้นหารายการสนทนาทั้งหมดจากโฟลเดอร์
  3. แสดงคุณสมบัติของรายการสนทนา เช่น ID, หัวข้อการสนทนา และสถานะธง.

โค้ดตัวอย่างต่อไปนี้แสดงวิธีการค้นหาการสนทนา.

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

คัดลอกการสนทนา

เพื่อคัดลอกการสนทนาจากโฟลเดอร์หนึ่งไปยังอีกโฟลเดอร์:

  1. เชื่อมต่อกับ Exchange Server ด้วยการใช้ IEWSClient อินเทอร์เฟซ
  2. เรียกใช้ IEWSClient.CopyConversationItems() เมธอดเพื่อคัดลอกรายการสนทนาจากโฟลเดอร์ต้นทางไปยังโฟลเดอร์ปลายทาง

โค้ดตัวอย่างต่อไปนี้แสดงวิธีการคัดลอกการสนทนา.

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

ย้ายการสนทนา

เพื่อย้ายการสนทนาจากโฟลเดอร์หนึ่งไปยังอีกโฟลเดอร์:

  1. เชื่อมต่อกับ Exchange Server ด้วยการใช้ IEWSClient อินเทอร์เฟซ
  2. เรียกใช้ IEWSClient.MoveConversationItems() เมธอดเพื่อย้ายการสนทนาจากโฟลเดอร์ต้นทางไปยังโฟลเดอร์ปลายทาง

โค้ดตัวอย่างต่อไปนี้แสดงวิธีการย้ายการสนทนา.

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

ลบการสนทนา

เพื่อลบการสนทนาจากโฟลเดอร์:

  1. เชื่อมต่อกับ Exchange Server ด้วยการใช้ IEWSClient อินเทอร์เฟซ
  2. เรียกใช้ IEWSClient.DeleteConversationItems() เมธอดเพื่อทำลายรายการสนทนาจากโฟลเดอร์ต้นทาง

โค้ดตัวอย่างต่อไปนี้แสดงวิธีการลบการสนทนา.

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