【发布时间】:2021-06-09 18:18:13
【问题描述】:
我需要发送带有我公司徽标的自动电子邮件。
我正在使用邮件对象的 HTMLBody 属性,但它不显示图像。相反,它显示了一个符号和 img HTML 标记的 alt 属性。
是否有一个特殊的目录,我必须在其中放置图像文件才能在邮件正文中使用它们?
Sub AutoMail()
'creating a CDO object
Dim Mail As CDO.Message
Set Mail = New CDO.Message
'Enable SSL Authentication
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Make SMTP authentication Enabled=true (1)
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Set the SMTP server and port Details
'Get these details from the Settings Page of your Gmail Account
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"smtp.gmail.com"
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Set your credentials of your Gmail Account
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = _
"****@****.com"
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = _
"*****"
'Update the configuration fields
Mail.Configuration.Fields.Update
'Set All Email Properties
With Mail
.Subject = "Test"
.From = "***@****.com"
.TextBody = "Hi"
.HTMLBody = "(message) <br> <br> <img alt='hi' src='C:\logo.png'>"
End With
'To send the mail
Mail.Send
Set Mail = Nothing
End Sub
【问题讨论】:
-
我尝试了这个问题的确切内容,但也没有工作。
-
更新您的问题以显示您尝试过的内容。