我想知道是否有可能知道谷歌日历中的事件何时被创建,我刚刚找到了如何创建一个事件并将其信息创建为另一个我希望将事件的信息发送到一个传播或任何文件
我刚拿到这个......
function createEvent() {
var calendarId = 'primary';
var eventSeries = CalendarApp.getDefaultCalendar().createEventSeries('Evento de prueba',
new Date('December 20 2014 10:00:00 AM -6'),
new Date('December 20 2014 10:30:00 AM -6'),
CalendarApp.newRecurrence().addWeeklyRule().
onlyOnWeekdays([CalendarApp.Weekday.SATURDAY]),
{ location: 'Tacos'});
Logger.log('EventSeriesID: ' + eventSeries.getId());
if (eventSeries.getTitle() == 'Evento de prueba'){
var calendarId2 = 'primary';
var event = CalendarApp.createEvent(eventSeries.getTitle(), eventSeries.getDateCreated(), new Date(eventSeries.getDateCreated() + 2),
{location : eventSeries.getLocation()});
}
}
答案 0 :(得分:1)
我不确定您是想要这种方式还是其他方式,但您可以尝试使用以下代码。
function createEvent() {
try{
var calendarId = 'primary';
var eventSeries = CalendarApp.getDefaultCalendar().createEventSeries('My Events',
new Date('December 20 2014 12:00:00 PM'),
new Date('December 20 2014 03:30:00 PM'),
CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekdays([CalendarApp.Weekday.SATURDAY]),
{ location: 'Tacos'});
Logger.log('EventSeriesID: ' + eventSeries.getId());
if (eventSeries.getTitle() == 'My Events'){
var calendarId2 = 'primary';
var event = CalendarApp.createEvent(eventSeries.getTitle(), eventSeries.getDateCreated(), new Date(eventSeries.getDateCreated() + 2),
{location : eventSeries.getLocation()});
var ss_id = logEventData(event);
Logger.log(ss_id);
sendMail(ss_id);
}
}catch(error){
Logger.log(error.message);
}
}
function logEventData(event) {
var ss = SpreadsheetApp.create('calender-events-logs');
var eventDetails = [];
eventDetails.push(event.getTitle());
eventDetails.push(event.getDescription());
eventDetails.push(event.getCreators()[0]);
//You can get number of other details here if you want to.
ss.appendRow(eventDetails);
return ss.getId();
}
function sendMail(ss_id) {
var emailTo = 'Put your email id here';
var subject = 'Test';
var body = 'Test';
var pdf = DocsList.getFileById(ss_id).getAs('application/pdf').getBytes();
var attachment = {fileName:'CalendarEventLogs.pdf',content:pdf, mimeType:'application/pdf'};
// Send the freshly constructed email
MailApp.sendEmail(emailTo, subject, body, {attachments:[attachment]});
//MailApp.sendEmail(recipient, subject, body);
// Delete the dummy spreadsheet
deleteDummySheet(ss_id);
}
function deleteDummySheet(ss_id) {
DocsList.getFileById(ss_id).setTrashed(true);
}