[英]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.