您好我正在尝试创建一个可以发送嵌入图像邮件但我想要自定义图像尺寸的宏因此我希望宏选择图像大小,即单元格中提到的宽度和高度,并在发送邮件之前调整大小。
我还想添加另外两个附加了Web链接的图像,这样当用户点击每个链接时,它会将它们带到相应的页面。但无法获得相同的代码。请帮忙。
我的代码如下
Sub SendMail()
Dim olApp As Object
Dim olMail As Object
For I = 2 To Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
With ws
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
End With
With olMail
.To = Cells(I, 2).Value
.cc = Cells(I, 3).Value
.bcc = Cells(I, 4).Value
.Subject = Cells(I, 5).Value
.Body = Cells(I, 6).Value
On Error Resume Next
.Attachments.Add Cells(I, 7).Value
.HTMLBody = .HTMLBody & "<img src = 'image1.jpg' "
& "width= Cells(I, 8).Value height=Cells(I, 9).Value ><br>"
.Attachments.Add Cells(I, 10).Value
On Error GoTo 0
.Display
.Send
End With
Next
Set olMail = Nothing
Set olApp = Nothing
MsgBox "Mails Sent Successfully"
End Sub`
答案 0 :(得分:0)
报价是罪魁祸首。我会用双引号括起来:
.HTMLBody = .HTMLBody & "<img src = 'image1.jpg' width=""" & Cells(I, 8).Value & """ height=""" & Cells(I, 9).Value & """ ><br>"