martedì 30 ottobre 2012

C# Google API - Insert Calendar Feed

If we want to insert a reminder/appointment (feed) in our calendar, using our application, the following code shows how to do it

private void InsertCalendarFeed()
            CalendarService service = new CalendarService("cl");

            service.setUserCredentials("", "yourPassword");

            EventEntry entry = new EventEntry();

            entry.Title.Text = txt_titolo.Text;
            entry.Content.Content = "the content of the feed";
            When w = new When();
            DateTime start = Convert.ToDateTime("start date--> dd/mm/yyyy hh:mm:ss");
            DateTime end = Convert.ToDateTime("end date--> dd/mm/yyyy hh:mm:ss");
            w.StartTime = start;
            w.EndTime = end;

                      //select the calendar where the feed will be inserted
            //"cmb_calendars" is a ComboBox on the form containing the calendar.
            // view: C# Google API - Retrieve Own Calendars List
            Uri postUri = new Uri("" + ((ComboboxItem)cmb_calendars.SelectedItem).Value.ToString() + "/private/full");

            AtomEntry insertedEntry = service.Insert(postUri, entry);
            // insert ok

** I want to remeber to go here to get  Application-specific password

My Two Cents...

Nessun commento:

Posta un commento