将超链接添加到Excel电子邮件正文

问题描述:

我正在尝试从excel生成电子邮件,但希望将超链接添加到电子邮件正文中.我希望超链接显示为文本而不是文件路径.

I am trying to generate emails from excel but want to add hyperlinks to the email body text. I want the hyperlinks to show as text and not the file paths.

我该怎么做?

我正在使用以下代码.

I am using the below code.

    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吗?

假设您正在使用Outlook自动化,请切换到HTML邮件格式:

Presuming your using outlook automation, switch to the HTML mail format:

.BodyFormat = olFormatHTML '// 2
.HTMLBody = strBody 

并为主体使用标记:

strBody = "Hello ..<br />next line ..." & _
          "Click <a href=""http://www.foo.com"">here</a> to ..."