在 google 日历事件删除时发送通知

Send notification on google calendar event delete

我想在删除活动时发送通知:

var certificate = new X509Certificate2("myp12filepath", "notasecret", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);

ServiceAccountCredential credential = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
        Scopes = Scopes
    }.FromCertificate(certificate));

BaseClientService.Initializer initializer = new BaseClientService.Initializer();
initializer.HttpClientInitializer = credential;
initializer.ApplicationName = ApplicationName;
var service1 = new CalendarService(initializer);

var googleCalendarEvent = service1.Events.Delete("calendarId", "eventId").Execute();

delete函数不接受这个link中提到的第三个参数(表示是否发送通知)(没有c#例子)

那么有没有办法在删除事件后发送邮件通知?

AFAIK,如果您想发送有关事件删除的通知,您需要将 sendNotifications 设置为 true,正如您给定的 link. And in addition to that, for a user to receive notifications, user's notification setting should also be checked for each of the calendars as mentioned in this forum and also as given here.[=15= 中提到的那样]

下面列出了打开或关闭通知的步骤:

You can choose whether to have notifications for events, and whether you want to get notifications over email or in your browser.

  1. Open Google Calendar on your computer.
  2. In the top right, click Settings (gear icon) > Settings.
  3. At the top of the page, click the Calendars tab.
  4. Next to your calendar's name, click Edit notifications.
  5. Click Add notification or edit an existing notification.
  6. At the bottom of the page, click Save.

Note: To get notifications on your computer, you need to have Google Calendar open in your browser.

最后,由于 C# 的示例不多,.NET client 可能会有所帮助。

创建删除请求实例并将通知指定为真。见下文。

var certificate = new X509Certificate2("myp12filepath", "notasecret", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);

ServiceAccountCredential credential = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
        Scopes = Scopes
    }.FromCertificate(certificate));

BaseClientService.Initializer initializer = new BaseClientService.Initializer();
initializer.HttpClientInitializer = credential;
initializer.ApplicationName = ApplicationName;
var service1 = new CalendarService(initializer);

EventsResource.DeleteRequest delReq = service1.Events.Delete("calendarId", "eventId");
delReq.SendNotifications = true;
var googleCalendarEvent = delReq.Execute();