You may have forgotten to set a breakpoint on the first line? This stops the debugger from running through the whole script.
The error is a know apps script issue but they've still not fixed it!This tutorial quickly demonstrates the main features of the Apps Script debugger.
I haven't looked for a script that specifically does this, but it would be very easy to adapt the one in this tutorial to do what you're looking for but this is the jist of creating events:
var cal = CalendarApp.getDefaultCalendar();
cal.createEvent("Busy", new Date("July 21, 2010 08:00:00 EST"), new Date("July 21, 2010 09:00:00 EST"));
Alternatively, ask on Stack Overflow, just search the tag "apps-script" for calendar, or ask the question with that tag.Does what it says on the tin. Learn how to edit Apps Scripts using a Google Spreadsheet and the Script Editor. This is a basic introduction tutorial.
Ok so this is an error thrown by the Apps Script debugger if you try to debug into one of the Array iterator functions (ie .forEach). The uiSendEmail iterates over the Range object this way.
To get the app authorized you need to go into the debugger and just Run the uiSendEmail function (not Debug). We made a whilstestop tour of the Debugger screencast to show you how to do this.
Let me know how you get on - this workaround is ugly but it does work so stick with it.Building on the first Tutorial, here we learn how to use a document template to create the email our script sends.