且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Google Apps脚本在日历上创建带有附件的事件

更新时间:2023-12-05 20:57:28

是的,这是可能的.首先,您必须启用

Yes, this is possible. First you must enable the Advanced Calendar Service. Then you can do something like this:

function createNewEvent() {
  var calendarId = ''; //Calendar Id String
  var fileId = ''; // File Id String
  var start = new Date('January 20, 2016 20:00:00 UTC');
  var end = new Date('January 20, 2016 21:00:00 UTC');
  var eventObj = {
    summary: 'Apollo 11 Landing',
    location: 'The Moon',
    description: 'Sample description',
    start: {dateTime: start.toISOString()},
    end: {dateTime: end.toISOString()},
    attachments: [{
        'fileUrl': 'https://drive.google.com/open?id=' + fileId,
        'title': 'Moon Docs'
    }]
  };
  var resp = Calendar.Events.insert(eventObj, calendarId, {'supportsAttachments': true});
  Logger.log(resp); // Check out the response in the logs!
}

有关更多选项,请查看事件文档.

For more options, check out the Events documentation.