2010-04-14 191 views
1

我使用下面的代码来创建谷歌日历提醒(使用谷歌API版本2为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); 

四处错误:对象引用未设置为一个实例的一个对象。

Thanx

回答

1

该条目是否存在?如果是这样,提醒是否存在? (我的意思是不是NULL)

从api link判断。您可以设置提醒前的事件添加到日历:

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

注意我还没有与谷歌API的工作,所以如果它工作与否我不能女士精品您应该调试应用程序并查看EventEntry和Reminders的值

+0

我创造entry.But如何*提醒必须添加后创建提醒? 我认为这(只在后期指定)是创建提醒的唯一方法。 – Preeti 2010-04-14 08:45:43

+0

是否存在条目的提醒对象,因为您向其中添加了提醒对象。你可以发表一些代码如何创建条目? – RvdK 2010-04-14 09:16:38

+0

ok !! !! ..我做到了!! ..请检查帖子 – Preeti 2010-04-14 09:34:06

0

您应该完成“entry”对象的更新。 使用entry.Update() 设置提醒对象.. 希望这有助于..

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

saveEntry.getReminder().add(reminder); 

你插入/更新动作后

+0

请正确格式化您的代码,请在问题或答案文本框中单击[橙色问号](http://i.imgur.com/GjKAG.png)以获取解释。谢谢! – Trufa 2011-06-14 16:41:18