我在使用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)
有没有办法对宏进行编码以确保电子邮件被推送?