How do I make the application.reminder event work?

后端 未结 3 962
难免孤独
难免孤独 2021-01-16 15:39

I have this code in a class module - as stated to on msdn and on this stackoverflow thread

Public WithEvents objReminders As Outlook.Reminders

Private Sub A         


        
3条回答
  •  失恋的感觉
    2021-01-16 16:25

    The actual ANSWER to this question is the following: If you are setting recurring appointments, and putting code in the Application_Reminder event on an appointment, the Reminder event will NOT fire unless you specifically set a Reminder period in the drop down within the Appointment itself.

    I played with this for days, the event would never fire unless it was a single Appointment - recurring never worked.

    Setting a recurring appointment with a Reminder time of 5 minutes and all is working perfectly.

    FYI here is some code that I use to send user information (self password reset) reminders on a monthly basis, using email templates stored in a local folder. Works perfectly now. Remember to create your own new category if sending auto-emails called something linke 'Send Mail'. Each appointment must be set to this category and is checked within the Sub.

        Private Sub Application_Reminder(ByVal Item As Object)
          Dim objMsg As MailItem
    
           On Error Resume Next
    
    
        'IPM.TaskItem to watch for Task Reminders
        If Item.MessageClass <> "IPM.Appointment" Then
          Exit Sub
        End If
    
        If Item.Categories <> "Send Mail" Then
          Exit Sub
        End If
    
         'Check which Template for Reminder we need to send by looking for the keyword in the Reminder Appointment
    
    If InStr(Item.Subject, "e-Expenses Password Resets") > 0 Then
        Set objMsg = Application.CreateItemFromTemplate("C:\Reminder Emails\e-Expenses Resetting your own password.oft")
    
    ElseIf InStr(Item.Subject, "e-Learning Password Resets") > 0 Then
        Set objMsg = Application.CreateItemFromTemplate("C:\Reminder Emails\e-Learning Resetting your own password.oft")
    
    ElseIf InStr(Item.Subject, "EMIS Password Resets") > 0 Then
        Set objMsg = Application.CreateItemFromTemplate("C:\Reminder Emails\EMIS Web Resetting your own password.oft")
    
    ElseIf InStr(Item.Subject, "NHS email Password Resets") > 0 Then
        Set objMsg = Application.CreateItemFromTemplate("C:\Reminder Emails\NHS Net eMail Resetting your own password.oft")
    
    ElseIf InStr(Item.Subject, "STRATA Password Resets") > 0 Then
        Set objMsg = Application.CreateItemFromTemplate("C:\Reminder Emails\STRATA Resetting your own password.oft")
    
    ElseIf InStr(Item.Subject, "VPN Password String Resets") > 0 Then
        Set objMsg = Application.CreateItemFromTemplate("C:\Reminder Emails\VPN Resetting your own password.oft")
    
    Else: Exit Sub
    
    End If
    
     'Location is the email address we send to, typically to ALL users
      objMsg.To = Item.Location
      objMsg.Subject = Item.Subject  'Make the subject of the Appointment what we want to say in the Subject of the email
      objMsg.Send
    
    
      Set objMsg = Nothing
    End Sub
    

    Have fun.

    Dave Thomas

提交回复
热议问题