Управление элементами беседы
Aspose.Email можно использовать для управления элементами беседы на Exchange Server с помощью класса EWSClient. Этот класс использует Exchange Web Services, которые доступны только в Exchange Server 2007 и более поздних версиях. В этой статье показано, как найти, скопировать, переместить и удалить элементы беседы на Exchange Server 2010. Для всех функций, включенных в этот раздел, требуется Microsoft Exchange Server 2010 Service Pack 1.
Поиск бесед
Чтобы получить информацию о беседе из определенной папки на Exchange Server:
- Подключитесь к Exchange Server с помощью класса IEWSClient.
- Вызовите метод FindConversations(), чтобы найти все элементы беседы в папке.
- Отобразите свойства элемента беседы, такие как ID, тема беседы и статус флага.
Следующий фрагмент кода показывает, как найти беседы.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-C | |
// Find Conversation Items in the Inbox folder | |
System::ArrayPtr<System::SharedPtr<ExchangeConversation>> conversations = client->FindConversations(client->get_MailboxInfo()->get_InboxUri()); | |
// Show all conversations | |
for (System::SharedPtr<ExchangeConversation> conversation : conversations) | |
{ | |
// Display conversation properties like Id and Topic | |
System::Console::WriteLine(System::String(u"Topic: ") + conversation->get_ConversationTopic()); | |
System::Console::WriteLine(System::String(u"Flag Status: ") + System::ObjectExt::ToString(conversation->get_FlagStatus())); | |
System::Console::WriteLine(); | |
} |
Копирование бесед
Чтобы скопировать беседы из одной папки в другую:
- Подключитесь к Exchange Server с помощью класса IEWSClient.
- Вызовите метод CopyConversationItems(), чтобы скопировать элемент беседы из исходной папки в папку назначения.
Следующий фрагмент кода показывает, как копировать беседы.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-C | |
System::SharedPtr<IEWSClient> client = GetExchangeEWSClient(GetExchangeTestUser()); | |
System::Console::WriteLine(u"Connected to Exchange 2010"); | |
try | |
{ | |
// Find those Conversation Items in the Inbox folder which we want to copy | |
System::ArrayPtr<System::SharedPtr<ExchangeConversation>> conversations = client->FindConversations(client->get_MailboxInfo()->get_InboxUri()); | |
for (System::SharedPtr<ExchangeConversation> conversation : conversations) | |
{ | |
System::Console::WriteLine(System::String(u"Topic: ") + conversation->get_ConversationTopic()); | |
// Copy the conversation item based on some condition | |
if (conversation->get_ConversationTopic().Contains(u"test email") == true) | |
{ | |
client->CopyConversationItems(conversation->get_ConversationId(), client->get_MailboxInfo()->get_DeletedItemsUri()); | |
System::Console::WriteLine(u"Copied the conversation item to another folder"); | |
} | |
} | |
} |
Перемещение бесед
Чтобы переместить беседы из одной папки в другую:
- Подключитесь к Exchange Server с помощью класса IEWSClient.
- Вызовите метод MoveConversationItems(), чтобы переместить беседу из исходной папки в папку назначения.
Следующий фрагмент кода показывает, как перемещать беседы.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-C | |
System::SharedPtr<IEWSClient> client = GetExchangeEWSClient(GetExchangeTestUser()); | |
System::Console::WriteLine(u"Connected to Exchange 2010"); | |
try | |
{ | |
// Find those Conversation Items in the Inbox folder which we want to move | |
System::ArrayPtr<System::SharedPtr<ExchangeConversation>> conversations = client->FindConversations(client->get_MailboxInfo()->get_InboxUri()); | |
for (System::SharedPtr<ExchangeConversation> conversation : conversations) | |
{ | |
System::Console::WriteLine(System::String(u"Topic: ") + conversation->get_ConversationTopic()); | |
// Move the conversation item based on some condition | |
if (conversation->get_ConversationTopic().Contains(u"test email") == true) | |
{ | |
client->MoveConversationItems(conversation->get_ConversationId(), client->get_MailboxInfo()->get_DeletedItemsUri()); | |
System::Console::WriteLine(u"Moved the conversation item to another folder"); | |
} | |
} | |
} | |
catch (System::Exception& ex) | |
{ | |
System::Console::WriteLine(ex.get_Message()); | |
} |
Удаление бесед
Чтобы удалить беседы из папки:
- Подключитесь к Exchange Server с помощью класса IEWSClient.
- Вызовите метод DeleteConversationItems(), чтобы удалить элемент беседы из исходной папки.
Следующий фрагмент кода показывает, как удалять беседы.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-C | |
System::SharedPtr<IEWSClient> client = GetExchangeEWSClient(GetExchangeTestUser()); | |
System::Console::WriteLine(u"Connected to Exchange 2010"); | |
try | |
{ | |
// Find those Conversation Items in the Inbox folder which we want to delete | |
System::ArrayPtr<System::SharedPtr<ExchangeConversation>> conversations = client->FindConversations(client->get_MailboxInfo()->get_InboxUri()); | |
for (System::SharedPtr<ExchangeConversation> conversation : conversations) | |
{ | |
System::Console::WriteLine(System::String(u"Topic: ") + conversation->get_ConversationTopic()); | |
// Delete the conversation item based on some condition | |
if (conversation->get_ConversationTopic().Contains(u"test email") == true) | |
{ | |
client->DeleteConversationItems(conversation->get_ConversationId()); | |
System::Console::WriteLine(u"Deleted the conversation item"); | |
} | |
} | |
} | |
catch (System::Exception& ex) | |
{ | |
System::Console::WriteLine(ex.get_Message()); | |
} |