我找不到向我的日历活动添加附件的方法。我希望应该有一个像下面的代码片段这样的简单方法,
function createNewEvent()
{
var file = DriveApp.getFileById('1eqaThzYmTbZzP-my file id-rXrBrWDW8DwMNeU'); //get file to be attached
var title = 'Apollo 11 Landing';
var startTime = new Date('January 20, 2016 20:00:00 UTC');
var endTime = new Date('January 20, 2016 21:00:00 UTC');
var options = {description:'Sample description', location: 'The Moon', attachments:file}; //can we add attachments like this?
var event = CalendarApp.getDefaultCalendar().createEvent(title, startTime, endTime, options);
}
这可能吗?
是的,这是可能的。首先你必须enable the 高级日历服务。然后你可以做这样的事情:
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!
}
如需更多选项,请查看活动文档.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)