Outlook 转发超出 window 定义的电子邮件

Outlook forwarding email outside of the window defined

我在 Outlook 2010 中设置了以下规则...

Apply this rule after the message arrives
from someone@email.com
and with Report in the subject
and which has an attachment
and on this computer only
run Project.ThisOutlookSession.MyScript

脚本如下...

Sub methodName(Item As Outlook.MailItem)
    Item.Body = "Please find attached"
    Item.Save

   Dim bolTimeMatch As Boolean

    bolTimeMatch = (Time >= #7:00:00 AM#) Or (Time <= #7:30:00 AM#)
    If bolTimeMatch Then
        Set myForward = Item.Forward
        myForward.Recipients.Add "abc@hotmail.com"

        myForward.Send
    End If

    Set myForward = Nothing

End Sub

我希望这封特定的电子邮件仅在 window 定义的时间(早上 7:00 - 7:30am)每天发送...但是它在 window 之外发送了电子邮件.我怎样才能将代码更改为仅在那个时间(英国时间)发送。

首先,Outlook对象模型提供了DeferredDeliveryTime属性,可以用来设置一个Date,表示邮件消息传递的日期和时间。

改用逻辑 And 运算符:

 bolTimeMatch = (Time >= #7:00:00 AM#) And (Time <= #7:30:00 AM#)

您也可以尝试使用 TimeValue(Now) 而不是 Time 语句。