Reminders Collection Events
The Reminders collection object is new to Outlook 2002 and is a child object of the Outlook Application object. The Reminders collection object represents all the Reminder items stored in the hidden Reminders folder of the mailbox of the user who is logged on. Reminder items include appointment reminders, task reminders, and follow-up flags for Mail and Contact items. Several new events for the Reminders collection object give you granular control over Reminder items. Because the Reminders collection object is a child of the Application object, you should instantiate it in the startup procedure for your COM Add-in or VBA code.
The Reminders collection object is the programmatic sibling of the new Reminders dialog box in Outlook 2002. The Reminders dialog box, shown in Figure 9-8, eliminates the clutter caused by individual reminders in previous versions of Outlook and places all pending reminders into a single dialog box.
Figure 9.8 - The Reminders dialog box allows convenient access to all pending reminders
BeforeReminderShow
This event occurs just before the Reminders dialog box is displayed. The following example sets the Cancel argument to True and displays a Custom Reminders dialog box named frmReminders:
Private Sub colReminders_BeforeReminderShow(Cancel As Boolean) Cancel = True 'Show Custom Reminders dialog box frmReminders.Show End Sub
ReminderAdd
This event occurs when a Reminder item is added to the Reminders collection. The following example changes the default reminder sound, depending on the Item class of the ReminderObject passed to the ReminderAdd event procedure. All appointment items play the Utopia sound, and all task items play the Splashsound. You cannot set the ReminderSoundFile property for Mail and Contact item follow-up flags.
Private Sub colReminders_ReminderAdd(ByVal ReminderObject As Reminder) Dim objAppt As AppointmentItem Dim objTask As TaskItem Set objItem = ReminderObject.Item Select Case objItem.Class Case olAppointment Set objAppt = objItem objAppt.ReminderOverrideDefault = True objAppt.ReminderSoundFile = "c:\sounds\utopia.wav" objAppt.ReminderPlaySound = True objAppt.Save Case olTask Set objTask = objItem objTask.ReminderOverrideDefault = True objTask.ReminderSoundFile = "c:\sounds\splash.wav" objTask.ReminderPlaySound = True objTask.Save End Select End Sub
ReminderChange
This event occurs after a Reminder item is changed in the Reminders collection. The item containing the reminder must be saved before the ReminderChange event will fire.
ReminderFire
This event occurs just before a Reminder item fires. The following example sends a notification to a pager device when the reminder fires:
Private Sub colReminders_ReminderFire(ByVal ReminderObject As Reminder) Dim strBody As String Dim objNotify As MailItem strBody = ReminderObject.Caption Set objNotify = objOutlook.CreateItem(olMailItem) objNotify.Body = strBody 'Must use trusted COM Add-in to prevent OM guard prompts objNotify.To = "5551212@mobile.att.net" objNotify.Send End Sub
ReminderRemove
This event occurs when a Reminder item is removed from the Reminders collection. Because the ReminderRemove event does not pass a ReminderObject, you cannot determine which reminder has been removed from the Reminders collection. A reminder is removed from the Reminders collection when any of the following events occur:
- A reminder is dismissed programmatically or by a user action.
- A reminder is turned off programmatically or by a user action in the item containing the reminder.
- The item containing a reminder is deleted.
- A reminder is removed from the Reminders collection with the Remove method.
Snooze
This event occurs when a user snoozes a Reminder item, either through the Outlook user interface or programmatically. The following example changes the text in the FlagRequest property if a user snoozes a flagged message that's marked High Importance:
Private Sub colReminders_Snooze(ByVal ReminderObject As Reminder) If ReminderObject.Item.Class = olMail Then Dim objMI As MailItem Set objMI = ReminderObject.Item If objMI.Importance = olImportanceHigh Then objMI.FlagRequest = "Urgent - Do not snooze!" objMI.Save End If End If End Sub
No comments:
Post a Comment