我正在 .Net
上测试 Google Calendar API v3
。我已经设法将事件添加到日历中,如下所示:
Google.Apis.Calendar.v3.Data.EventAttendee attendee = new Google.Apis.Calendar.v3.Data.EventAttendee();
attendee.Email = "[email]@gmail.com";
List<Google.Apis.Calendar.v3.Data.EventAttendee> event_attendees = new List<Google.Apis.Calendar.v3.Data.EventAttendee>();
event_attendees.Add(attendee);
Google.Apis.Calendar.v3.Data.Event new_event = new Google.Apis.Calendar.v3.Data.Event();
new_event.Summary = "GoogleCalendarTest: Testing Event 4";
new_event.Description = "Testing .Net Google Calendar API";
new_event.Location = "Offices";
new_event.Start = new Google.Apis.Calendar.v3.Data.EventDateTime();
new_event.Start.DateTime = DateTime.Now;
new_event.End = new Google.Apis.Calendar.v3.Data.EventDateTime();
new_event.End.DateTime = new DateTime(2014, 12, 15, 12, 0, 0);
new_event.Attendees = event_attendees;
service.Events.Insert(new_event, "[email]@gmail.com").Execute();
我认为这会自动向与会者发送邀请电子邮件,但似乎默认情况下不会发送,如 documentation 中所示.添加的sendNotifications
参数是一个可选参数,这个question显示了它是如何在 PHP
上完成的,但我不知道如何在 .Net
上添加它。
更新
找到一种在 .Net
上设置 sendNotifications
的方法:
Google.Apis.Calendar.v3.EventsResource.InsertRequest insert_event = new EventsResource.InsertRequest(service, new_event, "[email]@gmail.com");
insert_event.SendNotifications = true;
insert_event.Execute();
虽然仍然没有发送邀请电子邮件,但可能仍然做错了。
更新 2
版本问题?
我发现了这个问题:Google Calendar API for .Net: Email notifications not sent when creating calendar event ,这与我遇到的问题非常相似。卸载并安装 API 解决了问题...我试过了但仍然有同样的问题,当前版本:1.9.0
最佳答案
这对我有用:
EventsResource.InsertRequest request = service.Events.Insert(newEvent, "primary");
request.SendNotifications = true;
Event createdEvent = request.Execute();
关于c# - 找不到 sendNotifications 选项 Google Calendar api v3 .NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27292387/