从共享日历中的私人项目获取时间和日期

时间:2018-07-10 12:46:19

标签: vba outlook outlook-vba

我在一个共享Outlook日历的团队中工作。我们想知道何时我们的日历中都存在空白。我们每个人都有标记为私人的日历项目。

这里是迭代日历项的代码。它在给定共享日历的相关时间内打印日历项目。但是,尽管时间和日期在Outlook GUI中可见,但它排除了所有市场私有的项目。

Sub ShowCalendar(myNamespace, myRecipient)
    Dim CalendarFolder As Outlook.MAPIFolder
    Dim myStart As Date
    Dim myEnd As Date
    Dim strRestriction As String
    Dim oItemsInDateRange As Outlook.Items
    Dim oAppt As Outlook.AppointmentItem
    Dim oItems As Outlook.Items
    myStart = Date
    myEnd = DateAdd("m", 2, myStart)

    Debug.Print "Start:", myStart
    Debug.Print "End:", myEnd

    'Filter
    strRestriction = "[Start] >= '" & Format$(myStart, "dd/mm/yyyy hh:mm AMPM") & "' AND [End] <= '" & Format$(myEnd, "dd/mm/yyyy hh:mm AMPM") & "'"

    Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
    Set oItems = CalendarFolder.Items
    oItems.IncludeRecurrences = True
    oItems.Sort "[Start]"
    Set oItemsInDateRange = oItems.Restrict(strRestriction)

    For Each oAppt In oItemsInDateRange
        Debug.Print oAppt.Start & " - " & oAppt.Sensitivity & " - " & oAppt.Subject
    Next

End Sub

是否可以获取私人物品的日期,开始和结束时间?

0 个答案:

没有答案