2017-12-12 18 views
0

MS Outlook 2013 VBA (MS Exchange)를 사용하여 회사 회의실 일정 이벤트를 읽으려고합니다. 내 스크립트는 쓰기 권한이있는 캘린더에서만 작동하지만 회의실 공유 캘린더는 읽기 전용입니다. 그들에 내 스크립트를 시도하면 런타임 오류 '-2147221233 (8004010f)'가 표시됩니다.Outlook VBA 열려있는 읽기 전용 공유 교환 달력

Sub ShowOtherUserCalFolders() 
    Dim namespace As Outlook.namespace 
    Dim recipient As Outlook.recipient 
    Dim CalendarFolder As Outlook.Folder 

    Set namespace = Application.GetNamespace("MAPI") 
    Set recipient = namespace.CreateRecipient("calendar-name") 
    recipient.Resolve 
    MsgBox recipient.Name 
    'The name is shown correctly 

    If recipient.Resolved Then 
     Set CalendarFolder = namespace.GetSharedDefaultFolder(recipient, olFolderCalendar) 
     'This should display the calendar on the screen, but it fails 
     CalendarFolder.Display 
     Dim oItems As Outlook.Items 
     Set oItems = CalendarFolder.Items 
     'The oItems is empty when trying to use read-only calendar 
     MsgBox oItems.Count 
    End If 
End Sub 

읽기 전용 공유 일정에서 정보를 얻는 올바른 방법은 무엇입니까?

+0

네임 스페이스에서 최상위 폴더까지 폴더 트리를 "calendar-name"하위 폴더로 이동하십시오. https://stackoverflow.com/a/9077144 – niton

답변

0

폴더 트리를 해당 폴더로 이동할 수 있습니다.

Option Explicit 

Sub ShowOtherUserCalFolders1() 

    Dim CalendarFolder As Folder 
    Dim oItems As items 
    Dim currFolder_entryID As String 

    ' Walk the folder tree to the applicable folder 

    ' Right click on folder | Properties 
    ' General Tab | Location 
    ' \\Highest level name of shared Boardrooms\subfolder 

    Set CalendarFolder = Session.folders("Highest level name of shared Boardrooms") 
    Set CalendarFolder = CalendarFolder.folders("subfolder") 
    Set CalendarFolder = CalendarFolder.folders("boardroom name") 

    Set ActiveExplorer = CalendarFolder 
    Set oItems = CalendarFolder.items 
    MsgBox CalendarFolder & " has " & oItems.count & " items" 

End Sub 
0

entryID를 사용하여 회의실을 직접 참조 할 수 있습니다.

Option Explicit 

Sub ShowOtherUserCalFolders2() 

    Dim CalendarFolder As Folder 
    Dim oItems As items 
    Dim currFolder_entryID As String 

    ' Reference the boardroom directly with entryID 
    ' Open the applicable calendar 

    ' In the immediate pane 
    ' ?ActiveExplorer.CurrentFolder.EntryID 
    ' or 
    Debug.Print ActiveExplorer.CurrentFolder.EntryID 

    ' Once you know the entryID, hardcode and uncomment 
    'currFolder_entryID = "entryID shown in the immediate pane" 

    'Set CalendarFolder = Session.GetFolderFromID(currFolder_entryID) 

    'Set ActiveExplorer = CalendarFolder 
    'Set oItems = CalendarFolder.items 
    'MsgBox "" & CalendarFolder & " has " & oItems.count & " items" 

End Sub