[英]Embedding an HTML file with images in an Outlook email generated by Excel VBA
[英]Embedding image in html email from Excel VBA
我正在尝试使用 HTML 代码构建一个包含文本和图像(来自 Excel 的图表)的电子邮件。 我合并了我在网上找到的代码。
这是我到目前为止的图像:
FirstChartPath = ThisWorkbook.Path & "\Current Credit Usage.png"
ChartName = "Current Credit Usage.png"
'add the image in hidden manner, position at 0 will make it hidden
.Attachments.Add FirstChartPath, olByValue, 0
'Now add it to the Html body using image name
'change the src property to 'cid:your image filename'
'it will be changed to the correct cid when its sent.
.HTMLBody = .HTMLBody & "<br><B>CURRENT CREDIT USAGE:</B><br>" _
& "<img src='cid:Current Credit Usage.png'" & "width='500' height='200'>"
'& "<br>Best Regards, <br>Sumit</font></span>"
我在图像中看到一个“X”,表示无法显示链接的图像。
“该文件可能已被移动、重命名或删除。请确认链接指向正确的文件和位置”
将其更改为:
'Second part with the charts
FirstChartPath = ThisWorkbook.Path & "\Current Credit Usage.jpg"
ChartName = "Current Credit Usage.jpg"
'add the image in hidden manner, position at 0 will make it hidden
.Attachments.Add FirstChartPath, olByValue, 0
'Now add it to the Html body using image name
'change the src property to 'cid:your image filename'
'it will be changed to the correct cid when its sent.
.HTMLBody = .HTMLBody & "<br><B>CURRENT CREDIT USAGE:</B><br>" _
& "<img src='" & FirstChartPath & "'width='500' height='200'>"
'& "<br>Best Regards, <br>Sumit</font></span>"
工作了,我错过了一个“'”
您需要将图像添加为附件并设置PR_ATTACH_CONTENT_ID
属性: 在 Outlook 电子邮件中包含图片
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.