我想用 C# 添加一个循环事件。我在网上发现以下应该可以工作。当我运行插入条目的方法时,它在 EventEntry 上失败了 insertEntry = service.Insert(calendarUri, entry); 陈述 !
我收到此错误:“请求执行失败: https ://www.google.com/calendar/feeds/user@gmail.com/private/full?gsessionid=6eGsOTuhQ-YUVWp2BV_25g ”
当我删除重复代码时,一切正常!我注意到这段代码很老了!如何使用 .NET 库在 Google 日历上简单地添加定期事件?
EventEntry entry = new EventEntry();
entry.Title.Text = "Hello World !";
// Recurring event:
String recurData =
"RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20131010;BYDAY=SU\r\n";
Recurrence recurrence = new Recurrence();
recurrence.Value = recurData;
entry.Recurrence = recurrence;
string htmlDescription = "Woww, really ?";
if (htmlDescription != null && htmlDescription.Length > 0)
{
entry.Content.Type = "html";
entry.Content.Content = htmlDescription;
}
Where eventLocation = new Where();
eventLocation.ValueString = "Somewhere";
entry.Locations.Add(eventLocation);
DateTime start = DateTime.Now;
When eventTime = new When();
eventTime.StartTime = start;
DateTime endTime = DateTime.Now.AddHours(2);
eventTime.EndTime = endTime;
entry.Times.Add(eventTime);
eventTime.AllDay = true;
EventEntry insertedEntry = service.Insert(calendarUri, entry);