martedì 30 ottobre 2012

C# Google API - Create a Calendar

Sometimes, could be useful have differents calendar, for example one for work and one for privacy, the following code shows how to create a calendar.
The example shows how specify title, summary, and color of the calendar.


private void CreateCalendar()
        {
            CalendarService service = new CalendarService("appName");
            service.setUserCredentials("yourMail@gmail.com", "yourPassword");
            service.QueryClientLoginToken();

            CalendarEntry calendar = new CalendarEntry();
            calendar.Title.Text = "Calendar Title";
            calendar.Summary.Text = "Calendar Description";
            calendar.Hidden = false;
            calendar.Color = "#2952A3";

            Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
         
            CalendarEntry createdCalendar = (CalendarEntry)service.Insert(postUri, calendar);
        }


** 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...

Nessun commento:

Posta un commento