Adding hyperlinks to excel email body text

守給你的承諾、 提交于 2020-01-10 03:45:26

问题


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.

How would I go about doing this?

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

Can I use .Hyperlinks.Add?


回答1:


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

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

And use markup for the body:

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


来源:https://stackoverflow.com/questions/15224280/adding-hyperlinks-to-excel-email-body-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!