Dismiss Outlook reminder

故事扮演 提交于 2019-11-30 03:28:24

问题


I am having no luck dismissing an Outlook alert programmatically before it displays.

Private Sub Application_Reminder(ByVal Item As Object)
    Dim objRem As Reminder
    Dim objRems As Reminders
    If Item.Subject = "TESTING" Then
        'downloadAndSendSpreadReport
        Set objRems = Application.Reminders
        i = 0
        For Each objRem In objRems
            i = i + 1
            If objRem.Caption = "TESTING" Then
                objRems.Remove i
                If objRem.IsVisible Then
                    objRem.Dismiss
                End If
                Exit For
            End If
        Next objRem
        Item.ReminderSet = False
        Item.Delete
        'Item.Dismiss
    End If
End Sub

I want to use this appointment Item as a trigger to some macro without needing users to manually dismiss the reminder.

Seems to me, when this event is triggered, the reminder item is NOT visible, thus cannot be dismissed

I tried to remove it from the reminders set but this seems to delete the whole event from my calendar. Also, it will still display a STRANGE TITLE reminder not in ASCII.

I tried to set the reminderSet property of the appointment item to false, the reminder property still pops up.

So I am looking for a way to a) dismiss the reminder before it pops automatically/ b). dismiss the reminder after it pops automatically....or any workaround to do a scheduled MACRO in Outlook. (Please note that I do not have permission to use scheduled job in Windows nor VBS.)

Updates:

Now I have the following code. The reminder is being removed, but it will still pop out a reminder window with a caption like "There is no appointment/reminder" something like this.

The beforeReminderShow event is useful in the sense the Reminder Object isVisible = true

so I can dismiss out.. but the reminders windows will continue to pop up even if there's 0 event.

Private WithEvents olRemind As Outlook.Reminders
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
Set objRems = Application.Reminders
    For Each objRem In objRems
        If objRem.Caption = "TESTING" Then
            If objRem.IsVisible Then
                objRem.Dismiss
            End If
            Exit For
        End If
    Next objRem

End Sub

[Solved] - final edit
The final solution workable (I placed in "ThisOutlookSession" Module). Hope this helps others.

' declare this object withEvents displaying all the events
Private WithEvents olRemind As Outlook.Reminders
Private Sub Application_Reminder(ByVal Item As Object)
    Set olRemind = Outlook.Reminders
    ' RUN OTHER MACRO HERE
End Sub

Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

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

End Sub

回答1:


The only way I know how to do this is as follows.

You need this at the top of your module/class:

Private WithEvents olRemind As Outlook.Reminders

Then when you get your Outlook object you need to do this:

Set olRemind = olApp.Reminders

Where olApp is your Outlook Application object.

Now in your code you need to have this event:

Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

Once you put the WithEvents at the top then you will be able to see all the events you can use.

Now you can cancel this event and thus not see the reminder window.




回答2:


If you want to dismiss all the reminders, you can simply implement the following code (declare this object WithEvents displaying all the events):

Private WithEvents olRemind As Outlook.Reminders

Private Sub Application_Reminder(ByVal Item As Object)
    Set olRemind = Outlook.Reminders
    ' RUN OTHER MACRO HERE
End Sub

Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
    Cancel = True          
End Sub


来源:https://stackoverflow.com/questions/13283989/dismiss-outlook-reminder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!