Google Calendar API插入事件后,所有者与参会者未收到Gmail通知
解决方案
你的问题核心是**sendUpdates参数的位置错误**:这个参数是Google Calendar API events.insert接口的请求参数,不是事件(event)资源本身的属性,把它放在event对象里不会生效。
修改后的代码
function addManualEvent(){ var event = { 'kind': 'calendar#event', 'summary': 'Last Event 9', 'location': 'Masai School, Bangalore', 'description': 'Paty time', 'start': { 'dateTime': '2023-03-17T14:36:00.000Z', 'timeZone': 'UTC' }, 'end': { 'dateTime': '2023-03-17T14:37:00.000Z', 'timeZone': 'UTC' }, 'recurrence': [ 'RRULE:FREQ=DAILY;COUNT=1' ], 'attendees': [ {'email': 'sureshsingh11661@gmail.com','responseStatus':'needsAction'}, {'email': 'ritiksingh11661@gmail.com','responseStatus':'needsAction'} ], 'reminders': { 'useDefault': true, }, "guestsCanSeeOtherGuests": true } // 把sendUpdates作为请求参数传入,而非event资源的属性 var request = gapi.client.calendar.events.insert({ 'calendarId': 'primary', 'resource': event, 'sendUpdates': 'all' // 正确位置 }); request.execute(function(event) { console.log(event) window.open(event.htmlLink) },function(error) { console.error(error); }); }
额外检查项
- 确认日历所有者的Google账号通知设置:打开Google Calendar,进入「设置和共享」→「通知」,确保「活动创建」的邮件通知已开启。
- 检查参会者邮箱是否正确,且没有将Google Calendar的通知邮件标记为垃圾邮件。
- 确认你的API请求使用的权限范围包含
https://www.googleapis.com/auth/calendar(该权限允许发送通知),如果使用更受限的权限(如calendar.events)可能无法触发邮件通知。
内容的提问来源于stack exchange,提问作者Ritik
相关产品推荐
相关产品推荐

