Pages

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

No comments:

Post a Comment