1
votes

I would like to add a recurring event with C#. I found on the Web that the following should work. When I run the method to insert the entry, It fails on the EventEntry insertedEntry = service.Insert(calendarUri, entry); statement !

I get this error : "Execution of request failed: https://www.google.com/calendar/feeds/[email protected]/private/full?gsessionid=6eGsOTuhQ-YUVWp2BV_25g"

When I remove the recurrence code, everything works fine ! I noticed that this piece of code is pretty old ! How can I simply add a recurring event on Google Calendar with the .NET library ?

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);
2
"When I try it I get an error." is absolutely meaningless to everyone except you unless you tell us what "an error" means. Is it a compiler error? A runtime error? Where is the error happening? Please edit your question and explain the error you're getting, along with the exact error message you're seeing. Expecting us to read through your code trying to figure it out is going to make getting you help much slower.Ken White
I'm sorry you are right ! I edited with the exact error, which it still, to me, meaningless.yhcowboy

2 Answers

1
votes

Straight from Google (click the .NET example if it doens't come up as a default):Create Recurring Events

Hopefully this will give you some ideas if not out-right answer your question.

Cheers.

1
votes

Your recurrence string telling it when to end requires a full time entry. You simply said UNTIL=20131010. The question is 20131010 where? We can assume you want midnight, but then... midnight where?

String recurData =
"RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20131010T000000-05:00;BYDAY=SU\r\n";

The above change should make your event recur until Midnight US Eastern time on 2013-10-10.