Friday 26 July 2019

Search Google Calendar event for Guests

The following Google Apps Script is designed to search a specified Google Calendar event and extract details about the Guests attached to it (eg their email address and status). The script is standalone so it only logs the output but you could copy it into a Google Sheet and write the data into the spreadsheet.

The 'CalendarApp' is used to perform the task and we start by getting hold of the relevant event, which for the purposes of demonstrating is hard-coded into the Apps Script but is likely to be taken from a spreadsheet in reality.
var event = CalendarApp.getEventById(eventId);
Next we want to get a list of the Guests which will be returned as an array.
var guestList = event.getGuestList();
Finally we need to loop through each Guest and extract their email address and status.
for (var i=0; i<guestList.length; i++) {
    var guest = guestList[i];
    var guestEmail = guest.getEmail();
    var guestStatus = guest.getGuestStatus();
}
Search event for Guest list.gs

2 comments:

  1. Hi,
    is there anyway to include the organizer in the list ?

    ReplyDelete
    Replies
    1. Hi

      Yes, this blog post better fits what you want: https://www.pbainbridge.co.uk/2019/07/search-google-calendar-for-event-details.html.

      It sounds like you want the 'creator' of the event - so you would use 'getCreators()' - https://developers.google.com/apps-script/reference/calendar/calendar-event#getcreators

      Kind regards
      Phil

      Delete