A reader named Todd commented on my post Exporting Email Info for Panic’s StatusBoard saying
David I would love to try something similar to create an iCal export at timed intervals to the cloud and then use that in Google calendar now that the sync function is not supported in google calendar….say from Outlook 2010??
Exporting the calendar info in iCal format is surprisingly easy as long as you have Outlook 2007 or later. The export is all handled via the GetCalendarExporter method of any Outlook Folder object that points to a calendar. In this case, I’m assuming that Todd wants to export his primary (i.e. default) calendar. If he wants a different calendar, then that’s possible too, but will require more code. Since Todd wants to schedule the export, I’ve written the solution in VBScript. This allows Todd to create a scheduled task using Windows Task Scheduler that will run the script at whatever interval he desires. Todd didn’t say where in the cloud the export needs to go, so I wrote the solution under the assumption that Todd can reach the cloud through a normal file share. If that’s not possible and the cloud target is only reachable via FTP or something similar, then the solution would require some additional code. Once the solution runs, Todd can subscribe to the calendar in Gmail just as he could to any other internet calendar.
Outlook 2007 or later.
- Open Notepad.
- Copy the code below and paste it into Notepad.
- Edit the code as needed. I included a comment where changes are needed.
- Save the file. You can name it anything you want so long as the file extension is .vbs.
- Test the script by double-clicking it.
- Open Windows Task Scheduler.
- Create a new task.
- Set the task to run at whatever interval you choose.
- Set the task’s action to run a script and select this script as the one to run.
'On the next line, edit the path to the .ics file you want the calendar exported to Const SAVE_TO_PATH = "C:\SomeFolder\SomeFile.ics" 'On the next line, edit the number of days of calendar info to export Const DAYS_TO_EXPORT = 90 Const SCRIPT_NAME = "Export Calendar To iCal" Const olFullDetails = 2 Const olFolderCalendar = 9 Dim olkApp, olkSes, olkCal, olkSha Set olkApp = CreateObject("Outlook.Application") set olkSes = olkApp.GetNamespace("MAPI") olkSes.Logon olkApp.DefaultProfileName Set olkCal = olkSes.GetDefaultFolder(olFolderCalendar) Set olkSha = olkCal.GetCalendarExporter With olkSha .CalendarDetail = olFullDetails .IncludeWholeCalendar = False .IncludeAttachments = False .IncludePrivateDetails = True .RestrictToWorkingHours = False .StartDate = Date .EndDate = Date + DAYS_TO_EXPORT .SaveAsICal SAVE_TO_PATH End With Set olkSha = Nothing Set olkCal = Nothing olkSes.Logoff Set olkSes = Nothing Set olkApp = Nothing