Google Apps Script - Creating Calendar Events

2019-08-16 11:04发布

问题:

When creating a Calendar event is it possible for me to set the CREATED BY field, that appears once the event is created, based on the contents of a cell (e-mail addresses will be entered manually as it is a public form, the cell will be "D2")

Here's what I currently have:

function CreateEvent() {
var vSS = SpreadsheetApp.getActiveSpreadsheet();
var vS = vSS.getActiveSheet();  
var vStartDate = vS.getRange("B2").getValue();
var vEndDate = vS.getRange("C2").getValue();  
var calendar = CalendarApp.getCalendarById(
 'blahblah.com_79u2vjeeepkpra94hp12nbscc0@group.calendar.google.com');
var event =  calendar.createEvent('Apollo 11 Landing',
 new Date(vStartDate),
 new Date(vEndDate));
Logger.log('Event ID: ' + event.getId());
}

回答1:

The CREATED BY field will always show the name (or email) of the person who created the event... are you really wanting to cheat on this and show someone else's name ?