Outlook等待几秒钟然后执行

Rad*_*duS 7 vba outlook-vba

我在Outlook 2010中有一个简单的VBA代码,可以自动打印任何传入的电子邮件.

此脚本设置为每次通过规则进入电子邮件时运行.

这是代码:

Sub printradu(Item As Outlook.MailItem)
       MessageAndAttachmentProcessor Item, True
End Sub
Run Code Online (Sandbox Code Playgroud)

如何使此脚本等待10秒然后执行它.我需要这样的东西:

Sub printradu(Item As Outlook.MailItem)
       'Wait 10 seconds then execute the code below:
       MessageAndAttachmentProcessor Item, True
End Sub
Run Code Online (Sandbox Code Playgroud)

Viv*_*ain 13

尝试:

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
Run Code Online (Sandbox Code Playgroud)

要么:

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
Run Code Online (Sandbox Code Playgroud)

要么:

Sub printradu(Item As Outlook.MailItem)
    'Wait 10 seconds then execute the code below:
    Threading.thread.sleep(10000)
    MessageAndAttachmentProcessor Item, True
End Sub
Run Code Online (Sandbox Code Playgroud)

  • 1000毫秒只有1秒;) (3认同)