【发布时间】:2017-12-05 18:58:57
【问题描述】:
我正在尝试将工作表中的范围作为图像嵌入到 Outlook 邮件正文中。它正确保存了图片,但我只在 Outlook 邮件正文中看到空白图片。我在这里做错了什么?
Sub View_Email()
tName = Trim(MAIN.Range("tEmail"))
If Not tName Like "*@*.*" Then MsgBox "Invalid Email address": Exit Sub
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'File path/name of the gif file
Fname = ThisWorkbook.Path & "\Claims.jpg"
Set oCht = Charts.Add
STAT.Range("A3:G26").CopyPicture xlScreen, xlBitmap
With oCht
.Paste
.Export Filename:=Fname, Filtername:="JPG"
'.Delete
End With
On Error Resume Next
With OutMail
.To = tName
.CC = ""
.BCC = ""
.Subject = STAT.Range("C1").Value
.HTMLBody = "<html><p>Summary of Claim Status.</p>" & _
"<img src=" & Fname & "' height=520 width=750>"
.display
'.Send 'or use .Display
End With
On Error GoTo 0
'Delete the gif file
'Kill Fname
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
【问题讨论】:
-
调试代码并检查
Fname的值是多少,并手动检查文件是否存在。打开文件并检查图表是否导出 -
@SiddharthRout 是的,我确实检查了 fname 和图片,它们看起来都很好,但 Outlook 正文将图片显示为空白
-
哦,我知道为什么...一会儿发布答案
-
在看到损坏的图像/未在草稿电子邮件中显示后,我点击发送,图像在到达时正确显示。