Turn off reminders programatically

  • Thread starter Thread starter Adrian
  • Start date Start date
A

Adrian

Outlook 2007 SP1/Exchange 2007

I want to programmatically turn off reminders for all 'all day' events that
I receive. Can anyone give me some guidance of how I might do this. I have
some experience of using VBA, but none with Outlook.

Thanks for any help.

Adrian
 
There's 2 ways to do this:

1) Use a rule to run a script (How to create a script for the Rules Wizard
in Outlook:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q306108). When your
function fires, you'll have to call
NameSpace.GetDefaultFolder(olFolderCalendar) to get a MAPIFolder object.
Then use Find or Restrict with MAPIFolder.Items to look for the Appointment
Item that was created in the Calendar as soon as the message was delivered to
your Inbox. You'll probably have to compare not only the Subject properties,
but also Start and End to guarantee you get the correct event. Once you have
the AppointmentItem object, set ReminderSet to False and Save.

2) Instead of a rule, monitor the ItemAdd event for your Calendar. You can
do this by grapping the Items collection object for the Calendar during
Application_Startup, and use a module level var for Items that uses the
WithEvents keyword so you can trap the event. When the event fires, you can
clear ReminderSet for all new appointments, or just for ones that have not
been accepted or rejected.

Let me know if you have any questions.
 
Thanks for your suggestions.

I will have a look at this and let you know how I get on.

Adrian
 
Michael,

I just pasted your example code into 'This OutlookSession' but nothing seems
to happen. What have I done wrong?

Thanks again for your help.

Adrian.
 
After any changes you need to call the Application_Startup procedure. That's
automatically done when you restart Outlook. Additionally, set the security
settings (Tools/Macro/Security) so that VBA is executed at all.

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Sat, 23 Feb 2008 12:56:59 -0000 schrieb Adrian:
 
Michael,

Thanks for your advice. Below is the code I have. It is running the
Application_Startup but never runs Items_ItemAdd. Any ideas?

++++++++++++++++++++++++++++
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
On Error Resume Next
Dim Meet As Outlook.MeetingItem
Dim Appt As Outlook.AppointmentItem

If TypeOf Item Is Outlook.MeetingItem Then
Set Meet = Item

Meet.ReminderSet = False
Meet.Save


Set Appt = Meet.GetAssociatedAppointment(True)

If Not Appt Is Nothing Then
Appt.ReminderSet = False
Appt.Save
End If
End If
End Sub

++++++++++++++++++++++++++++
Thanks,

Adrian
 
Where do you know from that ItemAdd is not running? If you did not do that
already, set a breakpoint on the Private Sub Items_ItemAdd line (f9). Then
receive a MeetingItem into your Inbox, the code execution should stop at the
breakpoint. you can then walk trough it with f8 step by step and watch what
happens.

ItemAdd fires only if Outlook is running while items come in and if it's not
more than 16 items at once.

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Mon, 25 Feb 2008 19:59:29 -0000 schrieb Adrian:
 
Michael,

Thank you for your patience. It is now working.

Although I had tested it with items coming in, I suspect that was before I
changed the security. For some reason I thought it ran when Outlook opened,
and I had been testing that.

Just one quick final question please. I wanted to only turn off reminders
for all day events so I tried 'If Appt.AllDayEvent = True Then...', but
Appt.AllDayEvent seems to remain False for All Day Events. Why is that? I
have worked around this by testing if Appt.Duration = 1440 and this seems to
work.

Thanks again.

Adrian

If I receive an All Day Appointment
 
Back
Top