将超链接(Web)添加到Outlook电子邮件

时间:2019-01-08 23:24:22

标签: excel vba outlook outlook-vba

我在将超链接嵌入到诸如this之类的某些文本时遇到问题。

我正在从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

1 个答案:

答案 0 :(得分:2)

尝试使用 .HTMLBody

示例

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

MSDN HTMLBody Property

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

MSDN .Body Property

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