Skip to content
Advertisement

Google Calendar API – sendUPdate not working to

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.

enter image description here

The “sendUpdates” parameter has to be included, so my code looks something like this:

function createEvent() {
  var calendarId = 'primary';
  var start = getRelativeDate(1, 23);
  var end = getRelativeDate(1, 24);

  var event = {
    summary: 'Lunch Meeting',
    // location: 'The Deli',
    description: 'Testing.',
    start: {
      dateTime: start.toISOString()
      // dateTime: start
    },
    end: {
      dateTime: end.toISOString()
      // dateTime: end
    },
    attendees: [
      {email: 'SOMEONE@GMAIL.COM'},
    ],

    sendUpdates: 'all',
    sendNotifications: 'true',
  };

  event = Calendar.Events.insert(event, calendarId);

}

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.

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:

function createEvent() {
 const calendarId = 'primary';
 const start = getRelativeDate(1, 23);
 const end = getRelativeDate(1, 24);

 const event = {
   summary: 'Lunch Meeting',
   description: 'Testing.',
   start: {
     dateTime: start.toISOString()
   },
   end: {
     dateTime: end.toISOString()
   },
   attendees: [
     { email: 'attendee1@gmail.com' },
   ],
 };

 event = Calendar.Events.insert(event, calendarId, {
   sendUpdates: 'all'
 })
}
Documentation
Advertisement