【问题标题】:Change color to an All Day Event in google calendar with Apps script使用 Apps 脚本将颜色更改为谷歌日历中的全天活动
【发布时间】:2016-10-13 07:48:42
【问题描述】:

我在使用谷歌应用脚​​本更改谷歌日历中全天活动的颜色时遇到问题。 我测试了很多方法,但没有任何效果。

var event = CalendarApp.getCalendarById(calendrierId).createAllDayEvent(title,date).addPopupReminder(1440);

谁有解决办法

谢谢

【问题讨论】:

  • 我相信你只能为整个日历设置颜色,不能为特定事件设置颜色。逻辑上它应该在 EventSeries 对象中,但似乎也没有选项。
  • 嗨 Vytautas,标准活动可以,为什么不能全天活动?
  • 常规活动和全天活动相同,适用于常规活动的也适用于全天活动。据我所知,您根本无法为任何事件设置颜色

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


【解决方案1】:

您需要使用Advanced Calendar Service(必须是enabled before use。在脚本编辑器中选择资源> 高级Google 服务...,然后在Google Developers Console 中启用它。)

启用后,您可以使用 Events: insert 创建事件并使用 colorId 设置事件的颜色,示例如下:

function myFunction() {
  var calendarId = '{YOUR_CALENDAR_ID}';
  var date = "2016-12-25";
  var event = {
    summary: 'Christmas Day',
    location: 'Home',
    start: {
      date: date
    },
    end: {
      date: date
    },
    // Bold Red background.
    colorId: 11
  };
  Calendar.Events.insert(event, calendarId);
}

截至今天,事件有 11 种颜色可供选择,您可以使用 Calendar.Colors.get() 获取完整列表,但这里有一个表格,其中包含您可能更熟悉的 UI 中使用的名称:

|    name    | colorId | background |
|------------|---------|------------|
| Blue       |    1    |   #a4bdfc  |
| Turquoise  |    2    |   #7ae7bf  |
| Purple     |    3    |   #dbadff  |
| Red        |    4    |   #ff887c  |
| Yellow     |    5    |   #fbd75b  |
| Orange     |    6    |   #ffb878  |
| Turquoise  |    7    |   #46d6db  |
| Gray       |    8    |   #e1e1e1  |
| Bold Blue  |    9    |   #5484ed  |
| Bold Green |    10   |   #51b749  |
| Bold Red   |    11   |   #dc2127  |

【讨论】:

  • 是的,这看起来不错。正计划研究使用日历 API,但没有足够的时间检查和编写答案。但从我读过的内容来看,这将是唯一的方法(类似于我必须通过 Gmail API 来获取消息而不是线程)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-21
  • 2015-06-20
  • 1970-01-01
  • 1970-01-01
  • 2013-06-26
  • 2017-04-28
相关资源
最近更新 更多