3
我想嵌入工作表作爲圖像在Outlook郵件正文的範圍。它正確保存圖片,但我只在Outlook郵件正文中看到空白圖片。我在這裏做錯了什麼?嵌入圖片在Outlook郵件正文excel vba
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主體將圖片顯示爲空白 – newguy
哦,我知道爲什麼...一刻發佈答案 –