【发布时间】:2014-12-04 11:03:16
【问题描述】:
我正在.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 上添加它。
更新
想出一种方法将sendNotifications 设置在.Net 上:
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
【问题讨论】:
-
您能否检查参加者的日历设置(日历->编辑通知->新事件)中是否选择了电子邮件?如果未选择此选项,即使发送通知为“真”,与会者仍不会收到通知
-
是的,所有更新通知都选择了电子邮件....新事件、更改的事件、取消的事件和事件响应。我已经测试了更新和删除一个事件,它仍然没有发送任何电子邮件。
-
我尝试了同样的方法但无法发送通知邮件。
标签: c# php .net calendar google-calendar-api