Excel/vba 后期绑定 HTML 电子邮件

Excel/vba latebinding HTML email

我在 VBA 中编写了一些代码,旨在 excel 中的 运行 应该发送一封 html 电子邮件。这最初工作正常,但我试图延迟绑定我的代码,仍然发送了一封电子邮件,但是 HTML 以纯文本形式显示给收件人。我的代码是:

Dim oAPP As Object
Dim oItem As Object
Const olMailItem As Long = 0
Set oAPP = CreateObject("Outlook.Application")
Set oItem = oAPP.CreateItem(olMailItem)
With oItem
    .To = Worksheets("Emails").Cells(1, 2).Value
    .Subject = "Product set-up request"
    .BodyFormat = 2
    .Body = emailbody
    .send
End With

.Body = emailbody更改为.HTMLBody = emailbody