Home How to find Calendar ID
Reply: 1

How to find Calendar ID

thetemplar
1#
thetemplar Published in 2018-02-14 14:29:25Z

I need to find the ID of a Outlook Calendar. It is a public calendar with many contributors/users, but not listed as "shared".

I want to automatically export selected calendars to an *.ics. Currently I only can export my default folder with:

 Set oNamespace = Application.GetNamespace("MAPI")
 Set oFolder = oNamespace.GetDefaultFolder(olFolderCalendar) 
 Set oCalendarSharing = oFolder.GetCalendarExporter
 oCalendarSharing.SaveAsICal "C:\calendar.ics"

I need to add the "ThisOne" to the export. The properties do not have a location:

How to I find the ID, so I can use it with "GetFolderFromID()"? Or are there better ways to include the Calendar in the export or export it on its own?

Edit: Now I think I got the Calendar-ID by using

Set oNamespace = Application.GetNamespace("MAPI")
Set oFolderPicked = oNamespace.PickFolder
Set oFolder = oNamespace.GetFolderFromID(oFolderPicked.EntryID, oFolderPicked.StoreID)
Set oCalendarSharing = oFolder.GetCalendarExporter

but this throws a exception at the last line (GetCalendarExporter):

If I export in the GUI (File -> Save), it works without a problem...

(Later I dont want to use PickFolder and just hard-code the EntryID to the script)

niton
2#
niton Reply to 2018-02-16 21:26:55Z

This demonstrates how to get the EntryID of a folder.

Option Explicit

Sub entryIDFromActiveExplorer()

Dim entryIDStr As String

Dim uPrompt As String
Dim uTitle As String
Dim uDefault As String
Dim msg As String

' Select a folder in the folder view
' Do not use the calendar view

entryIDStr = ActiveExplorer.CurrentFolder.entryID

uPrompt = "To hardcode the entryID of the " & _
          Session.GetFolderFromID(entryIDStr) & _
          " folder, copy this ID"

' Copy from the immediate pane
Debug.Print uPrompt
Debug.Print entryIDStr

uTitle = Session.GetFolderFromID(entryIDStr)
uDefault = entryIDStr

msg = InputBox(Prompt:=uPrompt, Title:=uTitle, Default:=uDefault)

End Sub


Sub entryIDFromPickfolder()

' If you do not want to select a folder
'  in the normal way, from the GUI

Dim oFolderPicked As folder

Dim entryIDStr As String

Dim uPrompt As String
Dim uTitle As String
Dim uDefault As String
Dim msg As String

Set oFolderPicked = Session.PickFolder

If Not oFolderPicked Is Nothing Then

    entryIDStr = oFolderPicked.entryID

    uPrompt = "To hardcode the entryID of the " & _
              Session.GetFolderFromID(entryIDStr) & _
              " folder, copy this ID"

    ' Copy from the immediate pane
    Debug.Print uPrompt
    Debug.Print entryIDStr

    Set ActiveExplorer.CurrentFolder = Session.GetFolderFromID(entryIDStr)
    DoEvents

    uTitle = Session.GetFolderFromID(entryIDStr)
    uDefault = entryIDStr

    msg = InputBox(Prompt:=uPrompt, Title:=uTitle, Default:=uDefault)

End If

ExitRoutine:
    Set oFolderPicked = Nothing

End Sub
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316885 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO