Thierry Dalon
Thierry Dalon

Reputation: 916

Set reminders for recurring appointments

I am trying to set reminders for recurring appointments.

 If objAppointment.ReminderSet = False Then
     If objAppointment.IsRecurring Then
         'Dim objRecurrencePattern As RecurrencePattern
         'Set objRecurrencePattern = objAppointment.GetRecurrencePattern
         'Set objAppointment = objRecurrencePattern.GetOccurrence(objAppointment.Start)
         objAppointment.ReminderOverrideDefault = True
     End If

     objAppointment.ReminderSet = True
     objAppointment.ReminderMinutesBeforeStart = 15 ' Enter your default time
     objAppointment.Save
     Debug.Print "Reminder set for '" & objAppointment.Subject & "'."
 End If

I found this post in MS forum.

The reminder properties seems to be properly set in the VBA debugger but if I check the appointment in the calendar the reminder is still not set/effective.

Upvotes: 1

Views: 679

Answers (2)

Thierry Dalon
Thierry Dalon

Reputation: 916

In case the meeting is recurring you have to edit All Occurences <->Parent meeting See code here https://gist.github.com/tdalon/60a746cfda75ad191e426ee421324386

Sub CheckTodayReminders()
    ' https://www.datanumen.com/blogs/quickly-send-todays-appointments-someone-via-outlook-vba/
    Dim objAppointments As Outlook.Items
    Dim objTodayAppointments As Outlook.Items
    Dim strFilter As String
    Dim objAppointment As Outlook.AppointmentItem ' Object

    Set objAppointments = Application.Session.GetDefaultFolder(olFolderCalendar).Items
    objAppointments.IncludeRecurrences = True
    objAppointments.Sort "[Start]", False ' Bug: use False/descending see https://social.msdn.microsoft.com/Forums/office/en-US/919e1aee-ae67-488f-9adc-2c8518854b2a/how-to-get-recurring-appointment-current-date?forum=outlookdev


    'Find your today's appointments
    strFilter = Format(Now, "ddddd")
    'strFilter = "2019-03-07"
    strFilter = "[Start] > '" & strFilter & " 00:00 AM' AND [Start] <= '" & strFilter & " 11:59 PM'"
    Set objTodayAppointments = objAppointments.Restrict(strFilter)

    For Each objAppointment In objTodayAppointments
        Debug.Print "Check Reminder for '" & objAppointment.Subject & "'..."

        If objAppointment.IsRecurring Then

            Set objAppointment = objAppointment.Parent

        End If

        If objAppointment.ReminderSet = False Then


            objAppointment.ReminderSet = True
            objAppointment.ReminderMinutesBeforeStart = 15 ' Enter your default time
            objAppointment.Save
            Debug.Print "Reminder set for '" & objAppointment.Subject & "'."
        End If

    Next
    ' MsgBox "Meeting reminders were checked!"

End Sub

Upvotes: 0

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66215

If you are dealing with an instance of a recurring appointment or an exception (check the AppointmentItem.RecurrenceState property), set the reminder on the master appointment retrieved from the AppointmentItem.Parent property.

Upvotes: 2

Related Questions