Reputation: 1783
I set up the following rules in Outlook 2010...
Apply this rule after the message arrives
from [email protected]
and with Report in the subject
and which has an attachment
and on this computer only
runProject.ThisOutlookSession.MyScript
The Script is as follows...
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 "[email protected]"
myForward.Send
End If
Set myForward = Nothing
End Sub
I would like this particular email to only send daily in the window defined (7:00am - 7:30am)... However it sent the email outside of the window. How could I change the code to only send at that time (UK hours).
Upvotes: 0
Views: 82
Reputation: 49435
First of all, the Outlook object model provides the DeferredDeliveryTime property which can be used to set a Date indicating the date and time the mail message is to be delivered.
Use the logical And operator instead:
bolTimeMatch = (Time >= #7:00:00 AM#) And (Time <= #7:30:00 AM#)
Also you may try to use the TimeValue(Now) instead of Time statements.
Upvotes: 1