Outlook Wait a few seconds, then run

I have a simple VBA code in Outlook 2010 that automatically prints all incoming emails.

This script is configured to run every time an email arrives through a rule.

Here is the code:

Sub printradu(Item As Outlook.MailItem) MessageAndAttachmentProcessor Item, True End Sub 

How can I make this script wait 10 seconds and then execute it. I need something like this:

 Sub printradu(Item As Outlook.MailItem) 'Wait 10 seconds then execute the code below: MessageAndAttachmentProcessor Item, True End Sub 
+7
vba outlook-vba
source share
1 answer

Try:

 Sub printradu(Item As Outlook.MailItem) 'Wait 10 seconds then execute the code below: Application.Wait(Now + TimeValue("0:00:10")) MessageAndAttachmentProcessor Item, True End Sub 

Or:

 Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub printradu(Item As Outlook.MailItem) 'Wait 10 seconds then execute the code below: Sleep(10000) MessageAndAttachmentProcessor Item, True End Sub 

Or:

 Sub printradu(Item As Outlook.MailItem) 'Wait 10 seconds then execute the code below: Threading.thread.sleep(10000) MessageAndAttachmentProcessor Item, True End Sub 
+12
source share

All Articles