如何每 24 小时在 Outlook 中 运行 规则
How to run rules in Outlook every 24 hours
我目前在生产支持部门工作。我们将收到更多关于系统 CPU/RAM 利用率、作业失败等的电子邮件...每天我们将收到大约 300 到 500 封电子邮件 approx.We 已将电子邮件过滤到不同的文件夹中。但是,我不希望我们一收到电子邮件就这样做。
因为我们只关注来自企业用户的收件箱电子邮件。(大约 70 到 80 封电子邮件)。然而,电子邮件警报或触发器应该进入我的收件箱并一直保留到 00:00 然后规则应该 运行 并将邮件移动到相应的 inbox.How 我可以实现。可以这样做吗
看来您只需要 运行 Outlook 中的计时器 VBA:
Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLong
Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLong
Public TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is running
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
Public Sub DeactivateTimer()
Dim lSuccess As LongLong
lSuccess = KillTimer(0, TimerID)
If lSuccess = 0 Then
MsgBox "The timer failed to deactivate."
Else
TimerID = 0
End If
End Sub
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
上面显示的VBA宏是基于Windows提供的KillTimer
和SetTimer
函数。 SetTimer function creates a timer with the specified time-out value. The KillTimer 函数销毁指定的定时器。应用程序可以通过在 window 过程中包含 WM_TIMER case 语句或在创建计时器时指定 TimerProc
回调函数来处理 WM_TIMER
消息。当您指定 TimerProc
回调函数时,默认 window 过程会在处理 WM_TIMER
时调用回调函数。因此,您需要在调用线程中调度消息,即使您使用 TimerProc
而不是处理 WM_TIMER
.
请记住,要使计时器正常工作,您需要在系统上安装 Outlook 运行。
我目前在生产支持部门工作。我们将收到更多关于系统 CPU/RAM 利用率、作业失败等的电子邮件...每天我们将收到大约 300 到 500 封电子邮件 approx.We 已将电子邮件过滤到不同的文件夹中。但是,我不希望我们一收到电子邮件就这样做。
因为我们只关注来自企业用户的收件箱电子邮件。(大约 70 到 80 封电子邮件)。然而,电子邮件警报或触发器应该进入我的收件箱并一直保留到 00:00 然后规则应该 运行 并将邮件移动到相应的 inbox.How 我可以实现。可以这样做吗
看来您只需要 运行 Outlook 中的计时器 VBA:
Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLong
Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLong
Public TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is running
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
Public Sub DeactivateTimer()
Dim lSuccess As LongLong
lSuccess = KillTimer(0, TimerID)
If lSuccess = 0 Then
MsgBox "The timer failed to deactivate."
Else
TimerID = 0
End If
End Sub
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
上面显示的VBA宏是基于Windows提供的KillTimer
和SetTimer
函数。 SetTimer function creates a timer with the specified time-out value. The KillTimer 函数销毁指定的定时器。应用程序可以通过在 window 过程中包含 WM_TIMER case 语句或在创建计时器时指定 TimerProc
回调函数来处理 WM_TIMER
消息。当您指定 TimerProc
回调函数时,默认 window 过程会在处理 WM_TIMER
时调用回调函数。因此,您需要在调用线程中调度消息,即使您使用 TimerProc
而不是处理 WM_TIMER
.
请记住,要使计时器正常工作,您需要在系统上安装 Outlook 运行。