I made a disastrous mistake. I used Microsoft Flow to add my google calendar invites to outlook, and then my outlook calendars to google. Obviously this created a circular funhouse of calendar invites and now I have thousands of calendar events that is crashing my calendar from opening.
I'd like to mass delete all of these events. I created a Google script that deletes events with a specific subject line leveraging the the following:
function delete_events() {
var fromDate = new Date(2019,8,16,15,0,0);
var toDate = new Date(2019,8,18,11,0,0);
var calendarName = 'my email address';
var toRemove = 'Heather Unavailable';
var calendar = CalendarApp.getCalendarsByName(calendarName)[0];
var events = calendar.getEvents(fromDate, toDate,{search: toRemove});
for(var i=0; i<events.length;i++) {
var ev = events[i];//duplicate declaration
if(ev.getTitle()==toRemove) {//check if the title matches
var ev = events[i];//duplicate declaration
Logger.log(ev.getTitle()); // show event name in log
ev.deleteEvent();
}
}
}
However, I'm getting an error:
You have been creating or deleting too many calendars or calendar events in a short time. Please try again later. (line 18, file "Code")
Please help!