al-codaio / events-from-gmail

Create Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script.
11 stars 2 forks source link

Add event to specific Calenar #5

Closed bonelifer closed 2 years ago

bonelifer commented 2 years ago

It would be convenient to be able to add the event to a specific calendar instead of the default one.

bonelifer commented 2 years ago

Managed to get it done by changing "isAllDay" to this. Anyone looking here later you'll need to get your calendar id and replace the text below with it. Thanks for this script, really helps with managing my doctors appointments.

  if (isAllDay) {
    var event = CalendarApp.getCalendarById('<YOURCALENDARID>@group.calendar.google.com').createAllDayEvent(...calPayload)
  } else {
    var event = CalendarApp.getCalendarById('<YOURCALENDARID>@group.calendar.google.com').createEvent(...calPayload)
  }
  Logger.log('Event Added: ' + eventTitle + ', ' + startTime + '(ID: ' + event.getId() + ')');
}
al-codaio commented 2 years ago

@bonelifer Awesome glad you were able to figure it out! Thanks for posting the solution for others to see as well 👍