
我能夠透過 vba 中的程式碼建立定期電子郵件,每次觸發特定類別的提醒時都會觸發該程式碼。
http://www.slipstick.com/developer/send-email-outlook-reminders-fires/
我的問題是,郵件發送後如何取消提醒?當我加入行提醒(1)時。
如果我繼續執行,提醒最終會出現在 Outlook 中。
看來應用程式提醒巨集需要完成執行才能消除提醒事件。
答案1
根據 MSDN 的Applcation.Reminder
事件使用的 Slipstick 巨集被執行前出現提醒對話框。但是Reminder.Dismiss
方法要求提醒對話方塊中已顯示提醒(不確定是否必須相同)。這就是為什麼這不起作用。也就是說,據我所知,不能保證這Reminders(1)
將是剛剛觸發的提醒;您可能試圖忽略錯誤的提醒。
作為一個可能的解決方案(我必須強調,我沒有測試過),嘗試使用Reminders.Remove(Item.Subject)
.該文件似乎表明Reminders.Remove
需要數字索引,但值得一試。此外,如果帶有提醒的兩項具有相同主題,則無法保證您會得到正確的一項。
答案2
我自己也剛遇到這個問題。 j_foster 的想法似乎很有效。不過,最好使用約會項目的條目 ID 來識別通知的索引。然後就可以使用了remove()
。
見下文:
Private Sub Application_Reminder(ByVal Item As Object)
If TypeOf Item Is AppointmentItem Then
'Do Something...
'Loop over all reminders and find index of appt
Dim appt As AppointmentItem: Set appt = Item
Dim i As Integer: i = 0
Dim notif As reminder
For Each notif In Application.Reminders
i = i + 1
If notif.Item.EntryID = appt.EntryID Then
Call Application.Reminders.Remove(i)
Exit For
End If
Next
End If
End Sub