我在Outlook 2010中有一个简单的VBA代码,可以自动打印任何传入的电子邮件。
此脚本设置为每次通过规则收到电子邮件时都会运行。
以下是代码:
Sub printradu(Item As Outlook.MailItem)
MessageAndAttachmentProcessor Item, True
End Sub
如何使此脚本等待10秒然后执行它。我需要这样的东西:
Sub printradu(Item As Outlook.MailItem)
'Wait 10 seconds then execute the code below:
MessageAndAttachmentProcessor Item, True
End Sub
答案 0 :(得分:12)
尝试:
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
或者:
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
或者:
Sub printradu(Item As Outlook.MailItem)
'Wait 10 seconds then execute the code below:
Threading.thread.sleep(10000)
MessageAndAttachmentProcessor Item, True
End Sub
答案 1 :(得分:1)
这在Outlook 2013 VBA中对我有用(由于某些原因,我必须在“ Application.Wait”之前添加“ outlook。”)。
Outlook.Application.Wait (Now + TimeValue("0:00:5"))