我已经编写了一个脚本来创建一个基于 SQL 查询的 HTML 文件……有必要通过电子邮件发送该 HTML。我们的大多数高管都使用黑莓,我想将 HTML 文件作为正文发送。我找到了一种完成这项工作的方法,方法是添加一个 WebBrowser,然后让 Web 浏览器加载文件,然后使用下面的代码发送。我面临的问题是,如果我完全自动化代码,它只会通过电子邮件发送 HTML 文档的一部分,现在如果我添加一个按钮,并使其执行电子邮件功能,它会正确发送。我在几个不同的位置添加了一个等待功能,认为这可能是在发送电子邮件之前没有完全创建 HTML 的问题。我必须让这个 100% 自动化。有没有办法可以使用 .HTMLBody 链接到存储在 C:(实际路径是 C:\Turnover.html) 上的实际 HTML 文件。
Public Sub Email() Dim strdate Dim iCfg As Object Dim iMsg As Object
strdate = Date.Today.TimeOfDay
iCfg = CreateObject("CDO.Configuration")
iMsg = CreateObject("CDO.Message")
With iCfg.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxxxx.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = """Turnover Report"" <TurnoverReports@xxxxx.com>"
.Update()
End With
With iMsg
.Configuration = iCfg
.Subject = "Turnover Report"
.To = "xxxxx@xxxxx.com"
'.Cc = ""
.HTMLBody = WebBrowserReportView.DocumentText
.Send()
End With
iMsg = Nothing
iCfg = Nothing
End Sub