本文介绍了在 Outlook 邮件正文中嵌入图片 excel vba的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将工作表中的范围作为图像嵌入到 Outlook 邮件正文中.它正确保存图片,但我只在 Outlook 邮件正文中看到空白图像.我在这里做错了什么?
I am trying to embed a range from a worksheet as an image in outlook mail body. It's saving the picture correctly but I only see blank image in the outlook mail body. What am I doing wrong here?
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 将添加和隐藏它.
You need to add the image and hide it. The position 0 will add and hide it.
.Attachments.Add Fname, 1, 01 是 Outlook 常量 olByValue
The 1 is the Outlook Constant olByValue
添加图像后,您必须使用 "cid:FILENAME.jpg" ,如下所示.
Once you add the image then you have to use "cid:FILENAME.jpg" as shown below.
试试这个
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截图
更多推荐
在 Outlook 邮件正文中嵌入图片 excel vba
发布评论