我想用C#添加一个重复的事件。我在网上发现以下内容应该有效。当我运行插入条目的方法时,它失败了 EventEntry insertedEntry = 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);
答案 0 :(得分:1)
答案 1 :(得分:1)
您的重复字符串告诉它何时结束需要全时输入。你只是说UNTIL = 20131010。问题是20131010在哪里?我们可以假设你想要午夜,然后......午夜在哪里?
String recurData =
"RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20131010T000000-05:00;BYDAY=SU\r\n";
上述更改应使您的活动重复到2013-10-10美国东部时间午夜。