'Open.ics with Outlook 2013 to read items

This is specific to Office 2013.

In previous versions of Office (2010), I had a script which would download an .ics attachment and then save it to my calendar. After loading the .ics I then iterate through the .ics file and copy all AppointmentItem's to my calendar.

Dim oSharedFolder As Outlook.folder
Set oSharedFolder = _
    Application.GetNamespace("MAPI").OpenSharedFolder( _
    "C:\Temp\1421940003_event.ics")

However, in 2013 VBA the OpenSharedFolder method does not allow me to do this anymore, saying "The operation failed." In exploring the MSDN documentation I see:

OpenSharedFolder - This method does not support iCalendar appointment (.ics) files. To open iCalendar appointment files, you can use the OpenSharedItem method of the NameSpace object

Ok, great! They changed the name to OpenSharedItem instead (ignore their example using an .ics file.. which has the same error). However when I go there, I see:

OpenSharedItem - This method does not support iCalendar calendar (.ics) files. To open iCalendar calendar files, you can use the OpenSharedFolder method of the NameSpace object

So both these link to each other -- incorrectly, I might add, since both fail, even though both examples say they work for ics files.

My question is:

  • How can I open an .ics file with Outlook 2013 vba?


Solution 1:[1]

I can only think of either parsing the ICS file explicitly in your code or using Redemption (I am its author): it will let you import ICS files with a single event using RDOAppointmentItem.Import(..., olICal); multiple events in a single ICS file can be imported using RDOFolder2.Import:

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderCalendar)
set items = Folder.Import("c:\temp\MultipleItems.ics", olICal)
for each item in items
    debug.Print item.Subject
next

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1