1

我正在使用以下代码在 Google 日历中创建提醒(使用 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 Recurrence();
   recurrence.Value = recurData;
   entry.Recurrence = recurrence;

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

出现错误:对象引用未设置为对象的实例。

谢谢

4

3 回答 3

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

saveEntry.getReminder().add(reminder);

*插入/更新操作后必须添加提醒

于 2011-06-14T13:44:42.600 回答
1

条目是否存在?如果有,是否存在提醒?(我的意思是两者都不为NULL)

从 api链接来看。在设置提醒之前,您必须将事件添加到日历:

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

看到这个

注意我没有使用过 Google API,所以我不能保证它是否有效。您应该调试应用程序并查看 EventEntry 和 Reminders 的值

于 2010-04-14T08:19:47.210 回答
0

您应该完成“条目”对象的更新。在设置提醒对象后使用entry.Update() ..希望这会有所帮助..

于 2010-04-14T14:44:06.387 回答