You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google Calendar API v3仅向新增参会者发送邮件?

解决方案

要实现仅向新增参会者发送邀请通知,你需要使用Google Calendar API的Events.Invite方法,而非Patch或Update。Patch/Update操作的SendUpdates参数没有仅通知新增参会者的选项,而Invite方法正是为这种场景设计的——专门用于添加参会者并仅向新加入的人发送邀请邮件。

以下是修改后的C#代码:

var serviceCredential = GoogleCredential.FromJson(json)
    .CreateScoped("https://www.googleapis.com/auth/calendar.events")
    .CreateWithUser("impersonated_user@example.com");

using var calendarService = new CalendarService(new BaseClientService.Initializer
{
    HttpClientInitializer = serviceCredential,
    ApplicationName = "AppName",
});

// 准备新增的参会者列表
var newAttendees = new List<EventAttendee>
{
    new EventAttendee()
    {
        DisplayName = "Firstname Lastname",
        Email = "email@example.com"
    }
};

// 创建Invite请求
var inviteRequest = calendarService.Events.Invite(
    new Event() { Attendees = newAttendees }, 
    "<calendar_id>", 
    "<event_id>"
);

// 执行请求,仅新增参会者会收到通知
inviteRequest.Execute();

关键说明

  • Invite方法无需先获取整个事件对象,只需传入要添加的参会者列表即可。
  • 该方法会自动处理通知逻辑,仅向新添加的参会者发送邀请,不会打扰已有的参会者,完全匹配Google Calendar UI的操作体验。
  • 确保你的服务账号已被授予https://www.googleapis.com/auth/calendar.events权限,且被 impersonation 的用户拥有该日历事件的编辑权限。

内容的提问来源于stack exchange,提问作者jirkamat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 10:12:33