Link to home
Start Free TrialLog in
Avatar of David Kernaghan
David KernaghanFlag for United Kingdom of Great Britain and Northern Ireland

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
Avatar of Rgonzo1971
Rgonzo1971

Hi,

Maybe by placing in ThisOutlookSession
Private Sub Application_Startup() 

Application.Wait(Now + TimeValue("00:01:00"))
MsgBox "Welcome, " & Application.GetNamespace("MAPI").CurrentUser 
 
End Sub

Open in new window

Regards
Avatar of David Kernaghan

ASKER

Thanks,
I put that into the ThisOutlookSession bit and I after sorting out the macro issue, I got this error
User generated image
Thank you
David
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

Open in new window

Thanks, I really appreciate your help. I've got a different error now.
VBError2.jpg
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That worked brilliantly, thank you so much for that!

David
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
No I do not think it's possible
Shame. Thank you for all your help.
David
Solution according to author's comment