Working with Gmail Calendars

Adding, Editing and Deleting a Calendar

Aspose.Email allows applications to manage the Gmail calendars using IGmailClient which provides feature like adding, deleting and updating Gmail calendars. This client class returns list of ExtendedCalendar type objects which contain information about the Gmail calendar items. IGmailClient class exposes following functions for calendars:

  • CreateCalendar To insert new calendar
  • ListCalendars

Get list of all calendars of a client

  • DeleteCalendar It can be used to delete a calendar
  • Fetch Calendar It can be used to fetch particular calendar of a client
  • Update Calendar This function is used for inserting back a modified calendar of a client

To Access the calendars, GoogleTestUser is initialized using gmail account credentials. GoogleOAuthHelper is used to get the access token for the user which is further used to initialize IGmailClient.

Insert, Fetch and Update

For inserting a calendar, initialize a Calendar type object and insert it using CreateCalendar() function. CreateCalendar() returns the id of the newly inserted calendar. This id can be used to fetch the calendar from the server. The following code snippet shows you how to insert, fetch and update calendar.

Delete particular calendar

For deleting a particular calendar, we need to get the list of all the calendars of a client and then delete as required. ListCalendars() returns the list of ExtendedCalendar which contains Gmail calendars. The following code snippet shows you how to delete particular calendar.

Working with Calendar Access Control

Aspose.Email provides full control over the access control to the calendar items. ListAccessRules() function is exposed by IGmailClient which returns list of AccessControlRule. Individual rule information can be retrieved, modified and saved back for the calendar of a client. IGmailClient contains following functions for managing the access control rules.

  • ListAccessRules This function provides list of AccessControlRule
  • CreateAccessRule This function creates a new access rule for a calendar.
  • UpdateAccessRule This function is used for updating an access rule.
  • FetchAccessRule It can be used to fetch particular access rule for calendar of a client
  • DeleteAccessRule This function is used for deleting an access rule.

The following code snippet shows you how the functions used for managing the access rules:

Working with Client Settings and Color Info

Aspose.Email supports accessing the Client settings by using IGmailClient.GetSettings(). It returns list of settings as given below:

  1. dateFieldOrder
  2. displayAllTimezones
  3. hideInvitations
  4. format24HourTime
  5. defaultCalendarMode
  6. defaultEventLength
  7. locale
  8. remindOnRespondedEventsOnly
  9. alternateCalendar
  10. userLocation
  11. hideWeekends
  12. showDeclinedEvents
  13. weekStart
  14. weather
  15. customCalendarMode
  16. timezoneLabel
  17. timezone
  18. useKeyboardShortcuts
  19. country

Similarly color info for clients can also be retrieved using IGmailClient.GetColors(). This color info object returns the list of Foreground colors, background colors and update date and time.

Access client settings

The following code snippet shows you how the functions used for accessing the client settings:

Access color info

The following code snippet shows you how the functions used for accessing the client color settings.

Working with Appointments

Aspose.Email provides features for working with Appointments in Google calendars. Following is the list of tasks that can be performed on appointments in google calendar:

  1. Add Appointments.
  2. Retrieve list off appointments.
  3. Retrieve particular appointment.
  4. Update an appointment.
  5. Move appointment from one calendar to another.
  6. Delete appointment.

IGmailClient provides functions like CreateAppointment, FetchAppointment, UpdateAppointment, ListAppointments, MoveAppointment and DeleteAppointment.

Adding an appointment

Following code sample demonstrates the feature of adding an appointment in a calendar. In this sample following steps are followed:

  1. Create and insert a calendar.
  2. Retrieve list of appointments from a new calendar.
  3. Create an appointment.
  4. Insert appointment.

Retrieve and update appointment

Here retrieving and updating of calendar is demonstrated as follows:

  1. Rerieve particaulr appointment.
  2. Modify the appointment.
  3. Update the appointment in calendar.

It is assumed that a calendar with id “calendarId” and appointment unique id “AppointmentUniqueId” are already extracted. The following code snippet shows you how to retrieve and update appointment.

Move and Delete appointment

Appointment can be moved by providing the source calendar, destination calendar and unique id of appointment in the source calendar. The following code snippet shows you how to move and delete appointment.