开发者

Error in creating Google Calendar "Reminder"

I am using below code to create a reminder in Google calendar (using Google API ver 2 for c# ):

    EventEntry entry = new EventEntry();

    entry.Title.Text = "testing from .NET";
    entry.Content.Content = "testing from .NET";

    String recurData =
   "DTSTART;TZID=America/Los_Angeles:20071202T080000\r\n" +
   "DTEND;TZID=America/Los_Angeles:20071202T090000\r\n" +
   "RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20071230T160000Z;BYDAY=SU\r\n";

   Recurrence recurrence = new Recu开发者_StackOverflow中文版rrence();
   recurrence.Value = recurData;
   entry.Recurrence = recurrence;

   Reminder reminder = new Reminder();
   reminder.Minutes = 15;
   reminder.Method = Reminder.ReminderMethod.all;   
   entry.Reminders.Add(reminder);

Getting Error : Object reference not set to an instance of an object.

Thanx


Does the entry exist? If so, does Reminders exist? (I mean both not NULL)

Judging from the api link. You have to add the event to the calendar before setting reminders:

Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");
EventEntry createdEntry = (EventEntry) service.Insert(postUri, myEntry);
//and then add reminders

see this

Note I haven't worked with the Google API so I can't garantee if it works or not. You should debug the application and see the value of EventEntry and Reminders


CalendarEventEntry saveEntry = myService.insert(eventFeedUrl, entry);

saveEntry.getReminder().add(reminder);

*Reminder must add after you insert/update action


you should complete the update of the "entry" object. use entry.Update() after setting the reminder object.. hope this helps..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜