我目前正试图写一个自动化脚本,将发送出的电子邮件与图像在身体使用Gmail应用程序。下面是我的代码,我已经尝试,到目前为止,没有图像已显示在电子邮件正文。我只能添加图像作为附件,而不是作为主体。
Sub email_CDO()
Dim month As String
Set wb = ThisWorkbook
For iRow = 2 To wb.Sheets("client_list").Range("A1").CurrentRegion.Rows.Count
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "foukxizyifqoshhu"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Update
End With
With iMsg
Set .Configuration = iConf
.To = wb.Sheets("client_list").Cells(iRow, 2).Value
.CC = ""
.BCC = ""
.ReplyTo = "[email protected]"
.From = "[email protected]"
.Subject = "--" & " " & month & " " & page_name
.HTMLBody = "Hello " & page_name & _
"<br><br>--" & _
"<br><br>--" & _
"<br><br>--" & _
"<img src='C:\Users\foodpanda\Desktop\Email\Storage\email.jpg'>" & _
"<br><br><font size='1' font color='grey'>???????????????????????????.</font>"
If .To <> "" Then
.AddAttachment "C:\Users\Desktop\Email\Storage\example.jpg"
.Send
End If
End With
Next iRow
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
MsgBox "All email have been sent!"
End Sub
1条答案
按热度按时间slhcrj9b1#
试着改变那些线条
有了这些更新的台词,也许这会有所帮助
End If并确保文件email.jpg存在且路径正确