Search code examples
vbaemailoutlookdismissreminders

Outlook Reminders to E-Mail Script -- But Can't Dismiss


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 ...


Solution

  • 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