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.
Requirements.
Outlook 2007 or later.
Instructions.
- 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
David thanks again for your help with this…you script works perfectly for creating the ICal file but I have been less successful getting it to automate with Gmail. I have tried to set it up from G-drive, Onedrive and dropbox but google doesn’t like this as the url does not contain the actual file name. I tried to save it locally and use local file syntax for a url but it also did not like that. So I can import it from a local *.ics file but there is no clear way to automate this into the google calendar given my skill set anyway…I’ll do this manually for now and think on ways to get this to work…thanks for your help….this is an update on your work not a request for more help…thanks again
Todd
Todd,
Thanks for the update. I did some checking and it doesn’t look like any of the major file sharing services (e.g. Google, Box, DropBox, OneDrive) support WebDAV, which is required for internet calendar publishing/subscribing. Sorry, I should have checked into that ahead of time. If you have a web site, then you can copy the file to it and you should be able to subscribe to the calendar. Some ISPs give you some web space as part of your account. If your ISP is one of those that does, then check to see if you can FTP a file to your site. If that works, then I think we can come up with a solution for FTPing the file into your space. Note that anyone who can access your web site would probably be able to subscribe to your calendar and see what you’re doing. That could be a major security issue.
David, thanks for this. I will likely just set it to save to either the local one drive account or google drive account and link that to google calendar….I will let you know how I make out…Thanks again
Todd
You’re welcome, Todd!