【发布时间】:2016-11-20 21:29:34
【问题描述】:
我正在尝试每天下午 5 点发送一个打开的工作簿 (Excel)。这是我的代码:
我把这个放在一个模块中
Sub SendEmail()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "yourmail"
.CC = ""
.BCC = ""
.Subject = "Report"
.Body = "Hello!"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.OnTime TimeValue("17:00:00"), "SendEmail"
End Sub
我把这个放在 ThisWorkbook 中
Sub Workbook_Open()
Application.OnTime TimeValue("17:00:00"), "SendEmail"
End Sub
我的工作簿一直打开。 我无法收到电子邮件,除非我在 Excel 中点击了运行按钮。我希望它每天自动执行。
【问题讨论】:
标签: excel vba outlook excel-2007