embedded的图像从Excel VBA的HTML电子邮件

我试图build立一个自动的电子邮件,同时使用HTML代码的文本和图像(来自Excel的图表)。 这是我第一次写这样的代码,所以我抬头,合并了我在网上find的几个代码。 这是我迄今为止的形象:

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”,说链接的图像不能显示“该文件可能已被移动,重命名或删除。validation链接指向正确的文件和位置”任何人都可以发现错误?

将其更改为:

 '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>" 

工作,我错过了一个“'”