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();
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function searchForGuests() { | |
// Id of event to search Guests for | |
var eventId = 'your event Id'; | |
// get the event | |
var event = CalendarApp.getEventById(eventId); | |
// get a list of Guests | |
var guestList = event.getGuestList(); | |
// loop through each Guest to extract information *********************************** | |
for (var i=0; i<guestList.length; i++) { | |
var guest = guestList[i]; | |
var guestEmail = guest.getEmail(); | |
Logger.log('Guest name is: ' + guestEmail); | |
var guestStatus = guest.getGuestStatus(); | |
Logger.log('Guest status is: ' + guestStatus); | |
} | |
// end of loop through each Guest to extract information **************************** | |
} |
Hi,
ReplyDeleteis there anyway to include the organizer in the list ?
Hi
DeleteYes, 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