Outlook-Google Calendars Goal 3

Goal 3: Enumerate Google Appointment Lists (List Google Calendar Entries)
WARNING: I am using Visual Studio 2005 and C# (You’ve been warned)

For this goal I first did some looking on Google’s site. You can get the Google Calendar API Overview Here. It didn’t take long to discover that what I wanted was a Calendar Feed.

If you read some of the information out there, you may think that you need Google Calendar MagicCookie. You don’t. Actually I found that the appointment start and end times didn’t come over when I used this Magic Cookie link. To access your calendar feed in CSharp, all that you need is your username and password. Well, you also need the 3 GData DLLs supplied by Google.

These 3 DLLs can be downloaded with the Google Calendar Libraries here. These files are GData.dll, GCalendar.dll and GExtensions.dll. You add references to them in your C# project and then add the following using statements.

using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Calendar;

In my example I have simple Windows application written in C#. The form prompts for Username, password and a URL (or URI if you want to be exact).

The username is the part of your email address that appears before your gmail address. The password is your normal gmail password. The URL is
. Note the “user@gmail.com” part. This needs to be replaced with your GMail email address. In my example I change the url automatically.

//Create new query and service objects. These are all from gData.dll (Google.GData.Client) and gCalendar (Google.GData.Calendar).

FeedQuery Q = new FeedQuery();
CalendarService CS = new CalendarService(“CalendarTest”);

//Set the credentials.
CS.setUserCredentials(textBoxUsername.Text, textBoxPassword.Text);
GDataGAuthRequestFactory F = (GDataGAuthRequestFactory)CS.RequestFactory;

Q.Uri = new Uri(textBoxUrl.Text);

//Event Feed is in gextensions.dll (Google.GData.Extensions)
EventFeed EF = CS.Query(Q);
foreach (EventEntry EE in EF.Entries)
Start = DateTime.Parse(“1/1/2000 00:00″),
End = DateTime.Parse(“1/1/2000 00:00″);

//We only take the first time, even if there is more. We may need to handle multiple
// ones in the future.
if (EE.Times.Count > 0)
Start = EE.Times[0].StartTime;
End = EE.Times[0].EndTime;

MessageBox.Show(EE.Title.Text + “\n” +
EE.Content.Content + “\n” +
Start.ToString(“MM/dd/yyyy HH:mm”) + “\n” +
End.ToString(“MM/dd/yyyy HH:mm”));

Here’s the basic parts of the sourcecode. You can also download the full Google Calendar Enumeration Program Here.

0 thoughts on “Outlook-Google Calendars Goal 3”

  1. Hey, I tried click on the “You can also download the full Google Calendar Enumeration Program Here.” … but got a “The page cannot be found” error. I am trying to integrate this same type of functionality into one of the web applications, and was wondering if it was a windows app or a web app that you got this to work on.

Leave a Reply

Your email address will not be published. Required fields are marked *

− five = 0

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>