urdearboy
urdearboy

Reputation: 14590

Add hyper link (web) to Outlook email

I am having issues embedding a hyperlink to some text like this.

I am running the macro from Excel which creates a Outlook object and repeats for all values down column c.

The below did not work so, how do I go about embedding a link here?

.Body = "Click Here <https://www.google.com/>


Code below

Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
    If cell.Value Like "?*@?*.?*" And _
       LCase(Cells(cell.Row, "C").Value) = "yes" Then

        Set OutMail = OutApp.CreateItem(0)
        On Error Resume Next
        With OutMail

            .SentOnBehalfOfName = "[email protected]"
            .to = cell.Value

            .Subject = "Subject" & Cells(cell.Row, "D").Value
            .Body = "Click Here <https://www.google.com/>"

             strLocation = "C:\Users\hahayouthought"
            .Attachments.Add (strLocation)

            .Display
        End With
        On Error GoTo 0
        Set OutMail = Nothing
    End If
Next cell

Upvotes: 2

Views: 107

Answers (1)

0m3r
0m3r

Reputation: 12495

Try working with .HTMLBody

Example

.HTMLBody = "<A href=https://www.google.com/> Click Here </A>"

MSDN HTMLBody Property

Returns or sets a String representing the HTML body of the specified item. The HTMLBody property should be an HTML syntax string. Read/write.

MSDN .Body Property

Returns or sets a String representing the clear-text body of the Outlook item. Read/write.

Upvotes: 2

Related Questions