12

我正在尝试从 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吗?

4

1 回答 1

12

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

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

并为正文使用标记:

strBody = "Hello ..<br />next line ..." & _
          "Click <a href=""http://www.foo.com"">here</a> to ..."
于 2013-03-05T12:55:43.813 回答