0

I have looked into previous answers and tried many variations on the below, but I cannot seem to get it to work.

Basically, the purpose of the script below is to turn Outlook reminders into e-mail messages.

However, I cannot seem to programmatically dismiss the reminders. I've looked into prior answers to these questions (such as this one) and attempted to implement them, but they don't seem to succeed in this configuration.

' declare this object withEvents displaying all the events
Private WithEvents olRemind As Outlook.Reminders
Private Sub Application_Reminder(ByVal Item As Object)
  Dim objMsg As MailItem
  Dim objRem As Reminder
  Dim olRemind As Reminders
  Set olRemind = Outlook.Reminders
  Set objMsg = Application.CreateItem(olMailItem)
  objMsg.To = "*ADDRESS REMOVED FROM EXAMPLE*"
  objMsg.subject = "MHReminder: " + Item.subject
  objMsg.Body = Item.Body
  Set objMsg.SaveSentMessageFolder = Session.GetDefaultFolder(olFolderDeletedItems)
  objMsg.Send
  Set objMsg = Nothing
End Sub

Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

    For Each objRem In olRemind
        If objRem.IsVisible = True Then
            objRem.Dismiss
            Cancel = True
        End If
    Exit For
    Next objRem

End Sub

I'm a bit more of a "kludge-and-splice" programmer than a true programmer, so would appreciate anyone pointing out my (hopefully obvious) errors.

Thank you ...

Community
  • 1
  • 1

2 Answers2

0

You are looking at the first found reminder then quitting with

Exit For

As in the example you found Dismiss Outlook reminder you will need something like

For Each objRem In objRems
    If objRem.Caption = "TESTING" Then ' <--
        If objRem.IsVisible Then
            objRem.Dismiss
        End If
        Exit For
    End If
Next objRem
Community
  • 1
  • 1
niton
  • 8,771
  • 21
  • 32
  • 52
  • If this is the answer, do not accept. Delete the question. – niton Dec 23 '15 at 00:49
  • That doesn't seem to apply here -- basically, the script is supposed to convert ANY triggered reminder to e-mail, so I'm not seeking to test based on a caption. –  Dec 23 '15 at 05:05
  • The answer is really the same. You are processing the first reminder found then Exiting. To process every reminder drop the Exit For. I think though you will have to figure out how to identify the reminder that triggers each email and cancel only that one. – niton Dec 23 '15 at 05:22
  • How is for each reminder in Outlook.Reminders processing only the first one? –  Dec 23 '15 at 14:14
0

Cancel parameter in the BeforeReminderShow event handler needs to be ByRef.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78