Reputation: 189
I am trying to determine a method for inviting guests to an already created event using Google Script or Google Calendar API. just using addGuest(email) doesn't send an email invite when adding a guest after the event is created.
Is this the way to go about it?
var calid = 'some CalendarID';
var eventid = 'some eventid';
var ss = SpreadsheetApp.getActiveSpreadsheet();
var column = ss.getRange('A2:A2');
var emails = column.getValues();
var createdEvent = Calendar.Events.update(calid, eventid).attendees(emails);
I also saw this but it doesn't work.
function sendInvite(calendarId, eventId, emails) {
var event = Calendar.Events.get(calendarId, eventId);
event.attendees.push({email: emails});
event = Calendar.Events.patch(event, calendarId, eventId, {
sendNotifications: true
});
}
And this one:
function sendInvite(calendarId, eventId, email) {
var event = Calendar.Events.get(calendarId, eventId);
if(event.attendees) {
event.attendees.push({
email: email
});
} else {
event.attendees = new Array({email: email});
}
event = Calendar.Events.patch(event, calendarId, eventId, {
sendNotifications: true
});
}
Upvotes: 0
Views: 714
Reputation: 189
Turns out the Google event prevents the sending of past events by email. I was using a past date to test with. When I changed to a date in the future it worked great.
Upvotes: 1