David Kernaghan
asked on
Delaying rules from running
I understand that it is not possible to delay a client side rule from running, but I have heard that it is possible to create a VB script that can.
Situation is, a user has a rule that will print an email and it's attachment when it receives from a specific address. This rule will run as soon as the user opens their outlook ( 2016). I would like to delay this rule for a minute.
Can someone point me in the direction a code that might be able to do this?
Thank you
David Kernaghan
Situation is, a user has a rule that will print an email and it's attachment when it receives from a specific address. This rule will run as soon as the user opens their outlook ( 2016). I would like to delay this rule for a minute.
Can someone point me in the direction a code that might be able to do this?
Thank you
David Kernaghan
ASKER
then try
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'For 64-Bit
'Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub Pause(intSeconds As Variant)
' Comments: Waits for a specified number of seconds
' Params : intSeconds Number of seconds to wait
' Source : Total Visual SourceBook
On Error GoTo PROC_ERR
Dim datTime As Date
datTime = DateAdd("s", intSeconds, Now)
Do
' Yield to other programs (better than using DoEvents which eats up all the CPU cycles)
Sleep 100
DoEvents
Loop Until Now >= datTime
PROC_EXIT:
Exit Sub
PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , "Pause Method"
Resume PROC_EXIT
End Sub
Private Sub Application_Startup()
Pause 60
MsgBox "Welcome, " & Application.GetNamespace("MAPI").CurrentUser
End Sub
ASKER
Thanks, I really appreciate your help. I've got a different error now.
VBError2.jpg
VBError2.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked brilliantly, thank you so much for that!
David
David
ASKER
Now I have a second question, but it's not as important. Is it possible to have the rule delayed whilst outlook is open?
Thank you
David Kernaghan
Thank you
David Kernaghan
No I do not think it's possible
ASKER
Shame. Thank you for all your help.
David
David
Solution according to author's comment
Maybe by placing in ThisOutlookSession
Open in new window
Regards