Thursday, April 8, 2010

iCal not adding ics events if not using a local calendar

At my new consulting assignment they use ms exchange and I use apple mail and iCal synced with all my google calendars.

I use the google calendar as my primary calendar in iCal and had even deleted the local one. But, when I received event invites from exchange/outlook with .ics files they wouldn't open in iCal. iCal got the focus but the event was not added. After some experimenting I noticed that if I created a local calendar, the event got added, but only to the local calendar. The workaround for me was at first to manually save all the .ics attachments and use the import action in iCal, but after the 20:th invite, that routine got really old!!

After doing som searching i realized others where feeling the pain: http://www.google.com/support/forum/p/Calendar/thread?tid=1584cffedb7c8c18&hl=en
http://forums.macosxhints.com/archive/index.php/t-98833.html

Soo I created this applescript, you need to have a local calendar soo that events get picked up from apple mail. After running the script all those events are moved to a google calendar (or any other calendar) of your choice. A future improvement could be to make the script run in the background checking and moving events every minute or soo or to trigger it somehow when a local event is created, does anyone know how to do that?

I hope you find this script useful!
tell application "iCal"
 (* Change the calendar name to what ever you google calendar is called *)
 set googleCalendar to calendar "name of google calendar"
 
 (* change "local" below to what ever name you use *)
 tell calendar "local"
  set allLocalEvents to every event
  repeat with currentEvent in allLocalEvents
   
   (* Move the local event to gCal*)
   move currentEvent to the end of events of googleCalendar
   
   (*Del local event*)
   delete currentEvent
   
  end repeat
  
  (*Reload = upload new event to google*)
  reload calendars
  
 end tell
end tell



2 comments:

C said...

Awesome! I've been looking for a script to do this. Why can't Apple provide a setting to just set a CalDav calendar as your default? Instead, it treats local cals and CalDav ones differently.

Anonymous said...

Hooray this is fixed in 10.6.4!