martedì 30 ottobre 2012

C# Google API - Update Calendar Event

The following code shows how to update a calendar event, for example the title.


 private void UpdateEvent()
        {
            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService("appName");

            service.setUserCredentials("yourMail@gmail.com", "yourPassword");
            service.QueryClientLoginToken();
                   
                      // to get the Uru of the calendar event/feed go to:
                 // C# Google API - Retrieve All Calendar Feeds
            query.Uri = new Uri("the Uri of the event");

            EventFeed calFeed = service.Query(query) as EventFeed;
            AtomEntryCollection ee = calFeed.Entries;

            EventEntry ev = ee[0] as EventEntry;

            //in this example i modify the title of the event
            //but we can modify everything
            ev.Title.Text = "write the new title of the event";

            ev.Update();
            //update ok
        }

** I want to remeber to go here http://support.google.com/mail/bin/answer.py?hl=it&answer=1173270 to get  Application-specific password

My Two Cents...

1 commento: