我管理员创建了一个使用VBA代码通过gmail发送电子邮件的代码。 我的下一步是在HTML正文中插入一个范围。你能帮帮我吗?
代码:
Sub Send_mail()
Dim myMail As CDO.Message
Set myMail = New CDO.Message
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxx@xxxx.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxx"
myMail.Configuration.Fields.Update
Dim strHTML
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
With myMail
.Subject = "Position Match Check " & Now()
.From = "xxxx@xxxx.com"
.To = "xxxxk@xxxx.eu"
.TextBody = ""
.HTMLBody = strHTML
End With
On Error Resume Next
myMail.Send
MsgBox ("Mail Sent")
Set myMail = Nothing
End Sub
我想要添加到HTML正文的范围:
`Dim r As Range
Set r = Range("B6:J88")
r.Copy
Dim p As Picture
Set p = ActiveSheet.Pictures.Paste
p.Cut`
提前致谢