邮件中可点击的图片

问题描述 投票:0回答:1

我希望能够通过vba显示图像,让用户可以点击电子邮件,到目前为止,我有一个图片和文本,但我不知道如何使它,使收到电子邮件的人可以点击图像,使其发送到一个网页。

   Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    'OutApp.Session.logon
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next

    Fname = ThisWorkbook.Path & "\Logo.jpg"

    Dim cid As String
                    With OutMail

                    .to = companymail
                    .Subject = "Email Title"

                    .Body = strBody
                    .HTMLBody = "<html><p>First Text</p>" & _
                     "<img src=""cid:Logo.jpg""height=80 width=400>" & "<html><p>Second Text </p>"
                     .Attachments.Add Fname, 1, 0
                    .Attachments.Add fileaddress
                    .Display
                    End With

    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End If
excel vba outlook href
1个回答
0
投票

你需要包装 <img> 标记 <a> 标签。

<a href="URL/target.html">
<img src="src=""cid:Logo.jpg"" height=80 width=400 alt="an image" title="The title of this image" style="border-style:none"/>
</a>

另外,请记住,你需要为HTMLBody属性设置一个良好的HTML标记。这意味着你不能在关闭了 <html> 标签。你必须保持结构。

© www.soinside.com 2019 - 2024. All rights reserved.