首页 > 解决方案 > 将超链接(Web)添加到 Outlook 电子邮件

问题描述

我在嵌入指向此类文本的超链接时遇到问题

我正在从 Excel 运行宏,该宏创建一个 Outlook 对象并重复列 c 下的所有值。

以下内容不起作用,我该如何在此处嵌入链接?

.Body = "Click Here <https://www.google.com/>


下面的代码

Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
    If cell.Value Like "?*@?*.?*" And _
       LCase(Cells(cell.Row, "C").Value) = "yes" Then

        Set OutMail = OutApp.CreateItem(0)
        On Error Resume Next
        With OutMail

            .SentOnBehalfOfName = "urdearboy@needshelp.com"
            .to = cell.Value

            .Subject = "Subject" & Cells(cell.Row, "D").Value
            .Body = "Click Here <https://www.google.com/>"

             strLocation = "C:\Users\hahayouthought"
            .Attachments.Add (strLocation)

            .Display
        End With
        On Error GoTo 0
        Set OutMail = Nothing
    End If
Next cell

标签: excelvbaoutlook

解决方案


尝试与.HTMLBody

例子

.HTMLBody = "<A href=https://www.google.com/> Click Here </A>"

MSDN HTMLBody 属性

返回或设置一个表示指定项的 HTML 正文的字符串。HTMLBody 属性应该是一个 HTML 语法字符串。读/写。

MSDN .Body 属性

返回或设置一个表示 Outlook 项目的明文正文的字符串。读/写。


推荐阅读