繁体   English   中英

发送有关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();

删除功能不接受此链接中提到的第三个参数(指示是否发送通知)(没有c#示例)

那么,有什么方法可以在删除事件后发送电子邮件通知?

创建删除请求的实例,并将通知分配为true。 见下文。

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();

AFAIK,如果要发送有关事件删除的通知,则需要将sendNotifications设置为true ,这在给定链接中也提到了。 除此之外,为使用户接收通知,还应按照本论坛中提到的以及此处给出的每个日历检查用户的通知设置。

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

您可以选择是否具有事件通知,以及是否要通过电子邮件或在浏览器中获取通知。

  1. 在计算机上打开Google日历
  2. 点击右上角的设置(齿轮图标) >设置
  3. 在页面顶部,单击日历选项卡。
  4. 在日历名称旁边,点击编辑通知
  5. 单击添加通知或编辑现有通知。
  6. 在页面底部,点击保存

注意 :要在计算机上获取通知,您需要在浏览器中打开Goog​​le日历。

最后,由于没有太多的C#示例, .NET客户端可能会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM