Excel Outlook VBA:延迟交货时间:不工作
我正在测试延迟交付时间是否有效,并查看这些电子邮件是否未发送。我在发件箱里什么也没看到。 如果我只是发邮件的话,邮件会被发送出去。发送并发表评论。推迟发送时间。 此外,我还尝试在Outlook中手动更改Do not deliver before time,这确实有效。 所以我不确定VBA到底出了什么问题Excel Outlook VBA:延迟交货时间:不工作,excel,vba,email,outlook,Excel,Vba,Email,Outlook,我正在测试延迟交付时间是否有效,并查看这些电子邮件是否未发送。我在发件箱里什么也没看到。 如果我只是发邮件的话,邮件会被发送出去。发送并发表评论。推迟发送时间。 此外,我还尝试在Outlook中手动更改Do not deliver before time,这确实有效。 所以我不确定VBA到底出了什么问题 Option Explicit Private Sub CommandButton1_Click() Dim olApp As Outlook.Application Dim olMail
Option Explicit
Private Sub CommandButton1_Click()
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim olAccount As Outlook.Account
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = "my email"
.Subject = "test"
.Body = "test"
' .Send
.DeferredDeliveryTime = DateAdd("n", 10, Now)
End With
End Sub
根据我的测试,您应该更改.DeferredDeliveryTime=DateAddn,10,Now位置,如下所示:
Dim olAccount As Outlook.Account
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = "email address"
.Subject = "test"
.Body = "test"
.DeferredDeliveryTime = DateAdd("n", 10, Now)
.Send
End With
End Sub
此代码在我的电脑上成功运行。我想我还需要添加.Send after.DeferredDeliveryTime。这里的示例-不要这样做。下面的示例正在更改应用程序\u ItemSend函数,因此我认为它的工作方式与您认为的不一样。添加了。Send after.DeferredDeliveryTime=DateAddn,5,DateAddh,-5.5,现在所有电子邮件都立即发送。不知道为什么。我使用DateAddh,-5.5,现在在现在的位置调整时区。Outlook默认使用UTC时区,我需要将其转换为本地时区。无需更改时区。当手动更改延迟交货时间之前不发送时,我必须将时间更改为UTC。显然不需要在VBA中执行此操作。谢谢。添加。发送是我缺少的。DeferredDeliveryTime=DateAddn,10,现在不发送电子邮件..DeferredDeliveryTime将延迟发送电子邮件。你等了一段时间了吗?请参阅此链接:.DeferredDeliveryTime=DateAddn,10,现在将在十分钟后发送电子邮件。有关更多信息,请参阅此链接: