views:

152

answers:

2

Hi,

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 Recurrence();
   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

A: 

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

PoweRoy
i am creating entry.But how to create Reminders?I thought this (as specified in post ) is only way to create Reminders.
Preeti Singh
Well does the Reminders object of entry exist because you add a reminder object to it. Can you post some code how you create entry?
PoweRoy
ok.!!.. i did that!!..please check the post
Preeti Singh
can't you just set a breakpoint on the line that throws the error and check entry or Reminders if it's set. Entry seems set because else you would have an error each time you used it. Maybe it's something else, see updated post
PoweRoy
A: 

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

vikas