-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgoogle_home_mutiple_calendars.txt
31 lines (26 loc) · 1.03 KB
/
google_home_mutiple_calendars.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function addToGoogleHome() {
var calendarsWithName = {
"work": "work_email,
"school": "school_email",
"podcast" : "podcast_calendar_id"
"Roy": "Roy's_email"
};
var google_home_email = "personal_email/google_home_email";
var googleHomeCalendar = CalendarApp.getCalendarById(google_home_email);
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var num_events = 0;
for (var i in calendarsWithName) {
var calendarToCopy = CalendarApp.getCalendarById(calendarsWithName[i]);
var name = i;
if (calendarsWithName.size == 1) {
name = "";
}
var events = calendarToCopy.getEventsForDay(tomorrow);
for (var j = 0; j < events.length; j++) {
googleHomeCalendar.createEvent(name + " " + events[j].getTitle(), events[j].getStartTime(), events[j].getEndTime());
}
num_events = num_events + events.length;
}
GmailApp.sendEmail(google_home_email, "copied" + num_events + " events.", "");
}