Gmail 클라이언트를 사용하여 Google 캘린더 관리
Gmail 캘린더 추가, 편집 및 삭제
Aspose.Email는 애플리케이션이 Gmail 캘린더를 관리하도록 허용합니다 IGmailClient 이 클래스는 Gmail 캘린더 추가, 삭제 및 업데이트와 같은 기능을 제공하며, Gmail 캘린더 항목에 대한 정보를 포함하는 ExtendedCalendar 타입 객체 목록을 반환합니다. IGmailClient 클래스는 캘린더를 위한 다음 기능들을 제공합니다:
- CreateCalendar 새 캘린더를 삽입하는 데 사용할 수 있습니다.
- ListCalendars 클라이언트의 모든 캘린더 목록을 가져오는 데 사용할 수 있습니다.
- DeleteCalendar 캘린더를 삭제하는 데 사용할 수 있습니다.
- FetchCalendar 클라이언트의 특정 캘린더를 가져오는 데 사용할 수 있습니다.
- UpdateCalendar 이 함수는 클라이언트의 수정된 캘린더를 다시 삽입할 때 사용됩니다.
캘린더에 접근하기 위해 GoogleTestUser를 Gmail 계정 자격 증명으로 초기화합니다. GoogleOAuthHelper를 사용하여 사용자의 액세스 토큰을 얻고, 이를 사용해 IGmailClient를 초기화합니다.
Gmail 캘린더 삽입, 조회 및 업데이트
캘린더를 삽입하려면 Calendar 타입 객체를 초기화하고 다음을 사용하여 삽입합니다. CreateCalendar() 함수. CreateCalendar() 새로 삽입된 캘린더의 ID를 반환합니다. 이 ID는 서버에서 캘린더를 가져오는 데 사용할 수 있습니다. 다음 코드 스니펫은 캘린더를 삽입, 가져오기 및 업데이트하는 방법을 보여줍니다.
특정 Google 캘린더 삭제
특정 캘린더를 삭제하려면 클라이언트의 모든 캘린더 목록을 가져온 후 필요한 대로 삭제해야 합니다. ListCalendars() 목록을 반환합니다 ExtendedCalendar Gmail 캘린더를 포함합니다. 다음 코드 스니펫은 특정 캘린더를 삭제하는 방법을 보여줍니다.
캘린더 접근 제어
Aspose.Email은 캘린더 항목에 대한 접근을 완전하게 제어합니다. ListAccessRules() 함수는 아래에 의해 제공됩니다 IGmailClient 목록을 반환합니다. AccessControlRule. 개별 규칙 정보를 검색, 수정 및 클라이언트 캘린더에 다시 저장할 수 있습니다. IGmailClient 액세스 제어 규칙을 관리하기 위한 다음 기능들을 포함합니다.
- ListAccessRules 이 함수는 AccessControlRule 목록을 제공합니다.
- CreateAccessRule 이 함수는 캘린더에 대한 새 접근 규칙을 생성합니다.
- UpdateAccessRule 이 함수는 접근 규칙을 업데이트하는 데 사용됩니다.
- FetchAccessRule 클라이언트 캘린더에 대한 특정 접근 규칙을 가져오는 데 사용할 수 있습니다.
- DeleteAccessRule 이 함수는 접근 규칙을 삭제하는 데 사용됩니다.
다음 코드 스니펫은 접근 규칙을 관리하는 함수를 사용하는 방법을 보여줍니다:
캘린더 클라이언트 설정 및 색상 정보
Aspose.Email는 다음을 사용하여 클라이언트 설정에 접근하는 것을 지원합니다 IGmailClient.GetSettings(). 아래와 같이 설정 목록을 반환합니다:
- dateFieldOrder
- displayAllTimezones
- hideInvitations
- format24HourTime
- defaultCalendarMode
- defaultEventLength
- locale
- remindOnRespondedEventsOnly
- alternateCalendar
- userLocation
- hideWeekends
- showDeclinedEvents
- weekStart
- weather
- customCalendarMode
- timezoneLabel
- timezone
- useKeyboardShortcuts
- country
클라이언트의 색상 정보도 다음을 사용하여 검색할 수 있습니다 IGmailClient.GetColors(). 이 색상 정보 객체는 전경 색상, 배경 색상 및 업데이트 일시 목록을 반환합니다.
클라이언트 설정 접근
다음 코드 스니펫은 클라이언트 설정에 접근하기 위해 함수를 사용하는 방법을 보여줍니다:
색상 정보 접근
다음 코드 스니펫은 클라이언트 색상 설정에 접근하기 위해 함수를 사용하는 방법을 보여줍니다.
Google 캘린더 약속 관리
Aspose.Email은 Google 캘린더에서 약속을 작업하기 위한 기능을 제공합니다. 다음 작업을 Google 캘린더의 약속에 대해 수행할 수 있습니다:
- 약속을 추가합니다.
- 약속 목록을 검색합니다.
- 특정 약속을 검색합니다.
- 약속을 업데이트합니다.
- 약속을 한 캘린더에서 다른 캘린더로 이동합니다.
- 약속을 삭제합니다.
IGmailClient 다음과 같은 기능을 제공합니다: CreateAppointment, FetchAppointment, UpdateAppointment, ListAppointments, MoveAppointment 및 DeleteAppointment.
Google 캘린더에 약속 추가
다음 코드 샘플은 캘린더에 약속을 추가하는 기능을 보여줍니다. 이를 위해 다음 단계에 따라 수행하십시오:
- 캘린더를 만들고 삽입합니다.
- 새 캘린더에서 약속 목록을 가져옵니다.
- 약속 만들기.
- 약속을 삽입합니다.
Google 캘린더 약속 검색 및 업데이트
여기에 캘린더의 검색 및 업데이트가 다음과 같이 보여집니다:
- 특정 약속을 검색합니다.
- 약속을 수정합니다.
- 캘린더에서 약속을 업데이트합니다.
캘린더 ID가 "calendarId"이고 약속 고유 ID가 "AppointmentUniqueId"인 캘린더가 이미 추출된 것으로 가정합니다. 다음 코드 조각은 약속을 검색하고 업데이트하는 방법을 보여줍니다.
Google 캘린더에서 약속 이동 및 삭제
약속은 소스 캘린더, 대상 캘린더 및 소스 캘린더의 약속 고유 ID를 제공함으로써 이동할 수 있습니다. 다음 코드 조각은 약속을 이동하고 삭제하는 방법을 보여줍니다.
Google 캘린더용 FreeBusy 쿼리
Aspose.Email은 기준에 따라 약속이 예정되어 있는지를 확인하는 조회 메커니즘을 제공합니다. 이를 위해 FreebusyQuery 클래스가 제공되며, 특정 캘린더에 대한 쿼리를 준비할 수 있습니다.
이 코드 샘플은 캘린더 조회 기능을 보여줍니다. 이 샘플에서는 다음 작업을 수행합니다:
- 캘린더 생성 및 삽입
- 약속 만들기
- 약속 삽입
- FreeBusyQuery 준비하기
- FreebusyResponse 가져오기
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
// Use the GoogleUser and GoogleOAuthHelper classes below to receive an access token
using (IGmailClient client = GmailClient.GetInstance(accessToken, user.Email))
{
// Initialize calendar item
Aspose.Email.Clients.Google.Calendar calendar1 = new Aspose.Email.Clients.Google.Calendar("summary - " + Guid.NewGuid().ToString(), null, null, "Europe/Kiev");
// Insert calendar and get back id of newly inserted calendar and Fetch the same calendar using calendar id
string id = client.CreateCalendar(calendar1);
Aspose.Email.Clients.Google.Calendar cal1 = client.FetchCalendar(id);
string calendarId1 = cal1.Id;
try
{
// Get list of appointments in newly inserted calendar. It should be zero
Appointment[] appointments = client.ListAppointments(calendarId1);
if (appointments.Length != 0)
{
Console.WriteLine("Wrong number of appointments");
return;
}
// Create a new appointment and Calculate appointment start and finish time
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddHours(1);
// Create attendees list for appointment
MailAddressCollection attendees = new MailAddressCollection();
attendees.Add("user1@domain.com");
attendees.Add("user2@domain.com");
// Create appointment
Appointment app1 = new Appointment("Location - " + Guid.NewGuid().ToString(), startDate, endDate, "user2@domain.com", attendees);
app1.Summary = "Summary - " + Guid.NewGuid().ToString();
app1.Description = "Description - " + Guid.NewGuid().ToString();
app1.StartTimeZone = "Europe/Kiev";
app1.EndTimeZone = "Europe/Kiev";
// Insert the newly created appointment and get back the same in case of successful insertion
Appointment app2 = client.CreateAppointment(calendarId1, app1);
// Create Freebusy query by setting min/max timeand time zone
FreebusyQuery query = new FreebusyQuery();
query.TimeMin = DateTime.Now.AddDays(-1);
query.TimeMax = DateTime.Now.AddDays(1);
query.TimeZone = "Europe/Kiev";
// Set calendar item to search and Get the reponse of query containing
query.Items.Add(cal1.Id);
FreebusyResponse resp = client.GetFreebusyInfo(query);
// Delete the appointment
client.DeleteAppointment(calendarId1, app2.UniqueId);
}
finally
{
// Delete the calendar
client.DeleteCalendar(cal1.Id);
}
}