如何在CalendarEvent中添加图标(天赋)?

时间:2014-08-12 19:40:42

标签: google-apps-script google-calendar-api

我使用Google Apps脚本创建/编辑了一些CalendarEvents

如何在活动中添加图标?

我知道我可以使用Event Flairs gadget手动添加flairs。但是如何使用Google Apps脚本添加它们?

2 个答案:

答案 0 :(得分:1)

Google日历不提供对事件图标的原生支持,因此API或Apps脚本也不支持。

答案 1 :(得分:1)

使用the Advanced Calendar Service,这是可能的。 创建Google Apps脚本文件和enable the advanced calendar service.

然后创建一个像这样的函数:

function createEventWithFlair() {
var calendarId = "Enter calendarID here" 
var title = "Enter a title here"
var location = "Enter a location here"
var description = "Enter a description <b>here</b>" // simple html (<a><b>) is allowed
var startTime = "Sat May 26 23:59:59 GMT+02:00 2017" // must be an ISO-string ==> var date = new Date().toISOString();
var endTime = "Sun May 27 23:59:59 GMT+02:00 2017"

var gadget = {}
    gadget.display = "chip"   //Change to "icon" if you only want an icon to appear in the Google Calendar
    gadget.iconLink = "https://gamesrfunny.weebly.com/uploads/9/5/5/8/9558194/bird-blue.ico" //Link to ico-file.
    gadget.height = 20 
    gadget.width = 20
    gadget.type = 'image/ico'

var event = {
    summary: title,
    location: location,
    description:description,
    start: {
      dateTime: startTime
    },
    end: {
      dateTime: endTime
    },
    attendees: guests,
    // Red background. Use Calendar.Colors.get() for the full list.
    colorId: 11,
    gadget: gadget,

  };


var event = Calendar.Events.insert(event, calendarId);
Logger.log(event.htmlLink)
}

可以在resource representation页面中阅读完整的属性列表。