กรองการนัดหมายจาก Exchange Server
Contents
[
Hide
]
Aspose.Email สำหรับ C++ ช่วยให้ผู้พัฒนาสามารถกรองนัดหมายปฏิทินบน Microsoft Exchange โดยใช้ IEWSClient และ ExchangeQueryBuilder API คุณสามารถกรองนัดหมายตามช่วงวันที่ สถานะการทำซ้ำ หรือคุณสมบัตินัดหมายอื่น ๆ เพื่อดึงเฉพาะเหตุการณ์ที่คุณต้องการ.
ตัวอย่างในบทความนี้ใช้ส่วนหัวและเนมสเปซต่อไปนี้:
#include <Calendar/Appointment.h>
#include <Clients/Exchange/WebService/EWSClient/EWSClient.h>
#include <Clients/Exchange/WebService/EWSClient/IEWSClient.h>
#include <Clients/Exchange/Search/ExchangeQueryBuilder.h>
#include <Clients/Exchange/Search/AppointmentQueryBuilder.h>
#include <Tools/Search/MailQuery.h>
#include <Tools/Search/DateComparisonField.h>
#include <Tools/Search/BoolComparisonField.h>
#include <system/array.h>
#include <system/convert.h>
using namespace System;
using namespace Aspose::Email::Calendar;
using namespace Aspose::Email::Clients::Exchange;
using namespace Aspose::Email::Clients::Exchange::WebService;
using namespace Aspose::Email::Tools::Search;
กรองนัดหมายตามช่วงวันที่
นี้ Appointment สมาชิกของ ExchangeQueryBuilder ให้ฟิลด์ของรายการปฏิทิน เงื่อนไขบน Start และ End วันที่เลือกการนัดหมายในช่วงเวลา; GetQuery เปลี่ยนเป็น MailQuery ที่ ListAppointments ประเมินบนเซิร์ฟเวอร์
SharedPtr<IEWSClient> client = EWSClient::GetEWSClient(u"https://outlook.office365.com/ews/exchange.asmx", u"username", u"password");
SharedPtr<ExchangeQueryBuilder> builder = MakeObject<ExchangeQueryBuilder>();
builder->get_Appointment()->get_Start()->Since(DateTime(2025, 9, 15));
builder->get_Appointment()->get_End()->BeforeOrEqual(DateTime(2025, 10, 10));
ArrayPtr<SharedPtr<Appointment>> appointments = client->ListAppointments(builder->GetQuery());
Console::WriteLine(u"Appointments in the period: " + Convert::ToString(appointments->get_Length()));
client->Dispose();
กรองนัดหมายที่ทำซ้ำหรือไม่ทำซ้ำ
นี้ IsRecurring ฟิลด์แยกซีรีส์จากเหตุการณ์เดี่ยว ตัวอย่างแสดงการนัดหมายที่ไม่เป็นส่วนของซีรีส์
SharedPtr<IEWSClient> client = EWSClient::GetEWSClient(u"https://outlook.office365.com/ews/exchange.asmx", u"username", u"password");
SharedPtr<ExchangeQueryBuilder> builder = MakeObject<ExchangeQueryBuilder>();
builder->get_Appointment()->get_IsRecurring()->Equals(false);
ArrayPtr<SharedPtr<Appointment>> appointments = client->ListAppointments(builder->GetQuery());
for (SharedPtr<Appointment> appointment : appointments)
{
Console::WriteLine(appointment->get_Summary() + u" - " + appointment->get_StartDate().ToString());
}
client->Dispose();