我正在尝试从excel生成电子邮件,但想要添加到电子邮件正文文本的超链接。我希望超链接显示为文本而不是文件路径。
我将如何做到这一点?
我正在使用以下代码。
strBody = "Hello " & Range("QuoteFirstName").Value & "," & _
vbNewLine & _
vbNewLine & _
"It was good to speak with you earlier today/yesterday." & _
vbNewLine & _
vbNewLine & _
"[Any personal message]" & _
vbNewLine & _
vbNewLine
On Error Resume Next
With OutMail
.To = StrTo
.CC = ""
.BCC = ""
.Subject = StrSubject
.Body = StrBody
.Attachments.Add FileNamePDF
If Send = True Then
.Send
Else
.Display
End If
End With
我可以使用.Hyperlinks.Add
吗?
答案 0 :(得分:9)
假设使用outlook自动化,切换到HTML邮件格式:
.BodyFormat = olFormatHTML '// 2
.HTMLBody = strBody
并使用身体标记:
strBody = "Hello ..<br />next line ..." & _
"Click <a href=""http://www.foo.com"">here</a> to ..."