我知道存在以下链接。虽然我花了大量的时间研究,但我却空手而归。 https://support.office.com/en-sg/article/Manage-email-messages-by-using-rules-c24f5dea-9465-4df4-ad17-a50704d66c59
我知道你可以告诉它在规则向导中运行一个脚本,但触发它的事件不是我需要的。是否有我可以DL或创建的模板,这将允许我在特定时间使用Outlook来踢脚本?我不想在此过程中使用Windows任务计划程序。此外,我更喜欢不需要电子邮件触发器的方法 - 因为相关脚本将检查是否存在符合条件的电子邮件。也许有一种方法可以使用outlook Tasks(重复出现)作为触发器 - 但我还没有找到它。
任何和所有帮助将不胜感激。
答案 0 :(得分:0)
您可以在VBA中使用计时器来使您的代码按周期运行(例如,每N小时一次)。请查看Outlook VBA - Run a code every half an hour类似的主题以获取更多信息和示例代码。
另外,您可能会发现page有帮助。
将以下代码放在ThisOutlookSession模块中(Tools-> Macros-> VB Editor):
Private Sub Application_Quit()
If TimerID <> 0 Then Call DeactivateTimer 'Turn off timer upon quitting **VERY IMPORTANT**
End Sub
Private Sub Application_Startup()
MsgBox "Activating the Timer."
Call ActivateTimer(1) 'Set timer to go off every 1 minute
End Sub
将以下代码放入新的VBA模块
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long 'Need a timer ID to eventually turn off the timer.If the timer ID <> 0 then the timer is running
Public Sub ActivateTimer(ByVal nMinutes As Long)
nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes
If TimerID <> 0 Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer
TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)
If TimerID = 0 Then
MsgBox "The timer failed to activate."
End If
End Sub
Public Sub DeactivateTimer()
Dim lSuccess As Long
lSuccess = KillTimer(0, TimerID)
If lSuccess = 0 Then
MsgBox "The timer failed to deactivate."
Else
TimerID = 0
End If
End Sub
Public Sub TriggerTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)
MsgBox "The TriggerTimer function has been automatically called!"
End Sub