在outlook邮件正文excel vba中embedded图片

我试图从工作表中embedded范围作为图像在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 

您需要添加图像并隐藏它。 位置0将添加并隐藏它。

 .Attachments.Add Fname, 1, 0 

1是Outlook常数olByValue

一旦你添加图像,那么你必须使用"cid:FILENAME.jpg" ,如下所示。

尝试这个

 With OutMail .To = tName .CC = "" .BCC = "" .Subject = STAT.Range("C1").Value .Attachments.Add Fname, 1, 0 .HTMLBody = "<html><p>Summary of Claim Status.</p>" & _ "<img src=" & "cid:Claims.jpg" & "height=520 width=750>" .Display End With 

截图

在这里输入图像说明