在 Outlook 邮件正文中嵌入图片 excel vba

编程入门 行业动态 更新时间:2024-10-27 18:30:35
本文介绍了在 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, 0

1 是 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

本文发布于:2023-11-09 03:06:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文中   邮件   图片   Outlook   excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!