访问导入Outlook共享/团队日历

时间:2017-10-19 08:11:20

标签: vba ms-access outlook calendar

我正在使用Access中的Planning工具。我已设法导入我自己的日历并使用其中的约会。但是,我真正需要的是访问我的共享日历,以便检查我的同事是否忙碌。

目前我使用以下代码导入我的个人日历:

    Dim Outlook As Outlook.Application
    Dim namespace As Outlook.namespace
    Dim root As Outlook.MAPIFolder
    Dim cal As Outlook.MAPIFolder
    Dim Accepted As String
    Dim olRecipient As Outlook.Recipient    
    Dim item As Object
    Dim appt As Outlook.AppointmentItem    
    Dim rs As ADODB.Recordset

    Set Outlook = New Outlook.Application
    Set namespace = Outlook.GetNamespace("MAPI")
    Set root = namespace.GetFolderFromID("SomeMapIDiprobablyShouldntPostOnline")
     '--Setting "Agenda" to other names in the root doesnt work--
    Set cal = root.Folders.item("Agenda")

    Set rs = New ADODB.Recordset
    rs.ActiveConnection = CurrentProject.Connection
    rs.Open "Appointments", , adOpenDynamic, adLockOptimistic

    For Each item In cal.Items
      If item.Class = olAppointment Then
        Set appt = item

        rs.AddNew
        rs("Start") = appt.Start
        rs("End") = appt.End
        rs("Subject") = appt.Subject
        rs("Location") = appt.Location
        rs("Duration") = appt.Duration
        rs("Organizer") = appt.Organizer    
        rs("Attendees") = appt.Attendees
        rs.Update

      End If

    Next item

    rs.Close

我尝试过使用

  

GetSharedDefaultFolder("收件人",Outlook.OlDefaultFolders.olFolderCalendar)

E.g。

    Set Outlook = New Outlook.Application
    Set namespace = Outlook.GetNamespace("MAPI")
    Set olRecipient = namespace.CreateRecipient("Collegue Name")
    Set cal = namespace.GetSharedDefaultFolder(olRecipient, olFolderCalendar)
    olRecipient.Resolve

和不同的收件人对象,但我无法让它工作。任何提示将非常感谢。

0 个答案:

没有答案