我正在尝试使用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>"
我得到的问题是&#34; X&#34;在图像中说无法显示链接的图像
&#34;该文件可能已被移动,重命名或删除。验证链接是否指向正确的文件和位置&#34;
有人能发现错误吗?
答案 0 :(得分:0)
将其更改为:
'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>"
并且工作,我错过了一个&#34; &#39; &#34;
答案 1 :(得分:0)
您需要将图像添加为附件并设置PR_ATTACH_CONTENT_ID
属性:
Including Pictures in an Outlook Email