evoandy
evoandy

Reputation: 660

Adding hyperlinks to excel email body text

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?

Upvotes: 12

Views: 56892

Answers (1)

Alex K.
Alex K.

Reputation: 175936

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 ..."

Upvotes: 14

Related Questions