Home > Google API, VB.net > VB.net Add Calendar Entry Google API

VB.net Add Calendar Entry Google API

Adding a new calendar event to Google Calendar via the API is easier than I thought. Only a few lines of code to get a new calendar event setup and added. I did not do this with the “quick add” method, but that one looks even easier.

At the top:

Imports Google.GData.Calendar
Imports Google.GData.Extensions
Imports Google.GData.Client

I have this bit -o- code in a sub, called from a button click on my test app:

Dim newEvent As New EventEntry
Dim newatom As AtomEntry

Dim serv As New Google.GData.Calendar.CalendarService("GCal")
serv.setUserCredentials("you@email.com", "yourGPWD")
newEvent.Title.Text = "New Event Title"
newEvent.Content.Content = "This is the event description"
Dim newTime As New [When]()
newTime.StartTime = Convert.ToDateTime(DTSTB.text) 'getting date/time from textbox for testing
newTime.EndTime = DateAdd(DateInterval.Hour, 1, Convert.ToDateTime(TextBox3.Text)) 'add 1 hour for end

Dim uri As New Uri("https://www.google.com/calendar/feeds/default/private/full")
newatom = serv.Insert(uri, newEvent)

The “newatom” object as an Atomentry contains all of the details of the newly created event. I have to dig some more to find a good method for determining if the event was created correctly or not. Right now I’m looking at the URI for the event, making the assumption that if I get a URI back, the event was created properly.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: