Partager via


IncludeRecurrences Property

True if the Items collection should include recurrence patterns. This property only has an effect if the Items collection contains appointments and is not sorted by any property other than Start in ascending order. The default value is False. Read/write Boolean.

expression**.IncludeRecurrences**

*expression    * Required. An expression that returns one of the objects in the Applies To list.

Remarks

Use this property when you want to retrieve all appointments for a given date, where recurring appointments would not normally appear because they are not associated with any specific date. If the collection includes recurring appointments with no end date, setting the property to True may cause the collection to be of infinite count. Be sure to include a test for this in any loop.

You should not use Count property of Items collection when iterating Items collection with IncludeRecurrence property set to True. The value of Count will be an undefined value.

Example

The following Visual Basic for Applications (VBA) example displays the subject of the appointments that occur between today and tomorrow including recurring appointments.

Sub DemoFindNext()
    Dim myOlApp As Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Dim tdystart As Date
    Dim tdyend As Date
    Dim myAppointments As Outlook.Items
    Dim currentAppointment As Outlook.AppointmentItem
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    tdystart = VBA.Format(Now, "Short Date")
    tdyend = VBA.Format(Now + 1, "Short Date")
    Set myAppointments = myNameSpace.GetDefaultFolder(olFolderCalendar).Items
    myAppointments.Sort "[Start]"
    myAppointments.IncludeRecurrences = True
    Set currentAppointment = myAppointments.Find("[Start] >= """ & tdystart & """ and [Start] <= """ & tdyend & """")
    While TypeName(currentAppointment) <> "Nothing"
       MsgBox currentAppointment.Subject
       Set currentAppointment = myAppointments.FindNext
Wend
End Sub

Applies to | Items Object

See Also | IsRecurring Property | RecurrencePattern Object | RecurrenceType Property