相关疑难解决方法(0)

Excel VBA - 计算机锁定时不发送电子邮件

我在使用Excel VBA发送Outlook电子邮件时遇到问题.我有代码来做 - Sendupdate- 当我手动运行宏时,它工作正常.我的第二个宏StartTimer是为了在我不在我办公桌前的设定时间执行上述操作.

但是,当计算机被锁定时,电子邮件不会发送.当我回到我的办公桌时,电子邮件挂在那里作为草稿,我需要点击send按钮.

这是我的代码:

Sub SendUpdate()
Recipient = "x@y.com"
Subj = "update"
Dim msg As String
msg = "hello”

HLink = "mailto:" & Recipient & "?"
HLink = HLink & "subject=" & Subj & "&"
HLink = HLink & "body=" & msg
ActiveWorkbook.FollowHyperlink (HLink)
    Application.Wait (Now + TimeValue("0:00:01"))
    Application.SendKeys "%s"
End Sub

Sub StartTimer()
Application.OnTime TimeValue("18:00:00"), "SendUpdate"

End Sub
Run Code Online (Sandbox Code Playgroud)

有没有办法对宏进行编码以确保电子邮件被推送?

email outlook vba scheduled-tasks excel-vba

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

email ×1

excel-vba ×1

outlook ×1

scheduled-tasks ×1

vba ×1