مدیریت موارد مکالمه

Aspose.Email برای Java می‌تواند برای مدیریت موارد مکالمه در Exchange Server با استفاده از EWSClient کلاس. این کلاس از Exchange Web Services استفاده می‌کند که فقط در Exchange Server 2007 و نسخه‌های بعدی موجود است. این مقاله نشان می‌دهد چگونه پیدا کردن, کپی, جابجایی و حذف موارد مکالمه در Exchange Server 2010. سرویس‌پک 1 Microsoft Exchange Server 2010 برای تمام ویژگی‌های گنجانده‌شده در این بخش مورد نیاز است.

یافتن مکالمات

برای دریافت اطلاعات مکالمه از یک پوشهٔ خاص در Exchange Server:

  1. به Exchange Server با استفاده از کلاس IEWSClient متصل شوید.
  2. متد IEWSClient.findConversations() را صدا بزنید تا تمام موارد مکالمه را از یک پوشه پیدا کنید.
  3. خواص مورد مکالمه مانند شناسه، موضوع مکالمه و وضعیت پرچم را نمایش دهید.

قطعه کد زیر نشان می‌دهد چگونه مکالمات را پیدا کنید.

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. به Exchange Server با استفاده از کلاس IEWSClient متصل شوید.
  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. به Exchange Server با استفاده از کلاس IEWSClient متصل شوید.
  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. به Exchange Server با استفاده از کلاس IEWSClient متصل شوید.
  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");
    }
}