【发布时间】:2021-10-09 11:23:07
【问题描述】:
我使用 Excel 来群发邮件客户端。我的 VBA 代码找不到广告的 HTML jpeg。
是imgur链接不好还是我的代码?
MailWindows()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "insert here"
.Attachments.Add Fname, 1, 0
.HTMLBody = "<img src=""cid:"https://url.jpeg height=1650 width=1275>"
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
【问题讨论】:
-
检查您的报价。看到这里的代码变成橙色了吗?
-
请尝试
"<img src=""cid:"https://url.jpeg"" height=1650 width=1275>",并尝试定义Fname,它应该以某种方式与cell范围相关(可能在同一行的以下单元格中)。除此之外,使用Dim cell As Range也不好(甚至被 VBA 接受)。cell对 VBA 有明确的含义,如果代码变得更复杂,您或其他人在调试时可能会感到困惑。尝试使用Dim cel As Range,例如... -
以上建议没有解决您的问题吗?
-
谢谢。它和 Dmitry 解决了它。
标签: html excel vba outlook jpeg