Using Google App Script to create a Calendar event and having problems with the “sendUpdates” parameter to send email notifications on the creation of the calendar event.
According to the documentation here: events.insert.
The “sendUpdates” parameter has to be included, so my code looks something like this:
JavaScript
x
29
29
1
function createEvent() {
2
var calendarId = 'primary';
3
var start = getRelativeDate(1, 23);
4
var end = getRelativeDate(1, 24);
5
6
var event = {
7
summary: 'Lunch Meeting',
8
// location: 'The Deli',
9
description: 'Testing.',
10
start: {
11
dateTime: start.toISOString()
12
// dateTime: start
13
},
14
end: {
15
dateTime: end.toISOString()
16
// dateTime: end
17
},
18
attendees: [
19
{email: 'SOMEONE@GMAIL.COM'},
20
],
21
22
sendUpdates: 'all',
23
sendNotifications: 'true',
24
};
25
26
event = Calendar.Events.insert(event, calendarId);
27
28
}
29
However, upon running the above function, I don’t see any email notification about the Calendar Event being created.
Has anyone faced similar issues and have found a resolution?
Thanks.
Advertisement
Answer
You need to add the sendUpdates
parameter as an optional argument (sendNotifications
is not necessary) of
the Calendar.Events.insert
, not inside the body request:
JavaScript
1
24
24
1
function createEvent() {
2
const calendarId = 'primary';
3
const start = getRelativeDate(1, 23);
4
const end = getRelativeDate(1, 24);
5
6
const event = {
7
summary: 'Lunch Meeting',
8
description: 'Testing.',
9
start: {
10
dateTime: start.toISOString()
11
},
12
end: {
13
dateTime: end.toISOString()
14
},
15
attendees: [
16
{ email: 'attendee1@gmail.com' },
17
],
18
};
19
20
event = Calendar.Events.insert(event, calendarId, {
21
sendUpdates: 'all'
22
})
23
}
24