wornout8
wornout8

Reputation: 1

How to add multiple hyperlinks to email body from Excel vba

I have been googling for an answer for this for 2 weeks now I have clicked on every link there is maybe I am not asking the right way.
In Sheet17.Range("AC" & Lastrow & ":" & "AM" & Lastrow) I have some hyperlink address not all of those cells are filled
I am trying to get these address into my email body as separate clickable link. I would love to have the name only but would be happy for the link.

This is my email body

   xStrBody = "Hi there:" & NRes & "<br>" _
                & emailfrm.Body & "<br>" _
         & "Click <a href=""https://form.jotform.com/202217530090846"">here</a> to ..."

This works for the one I have hardcoded but I don't know how to get the ones from the cells in there.
At this stage I am prepared to change my worksheet to make it easier to get the links in the email even if I have to put in another separate worksheet

Upvotes: 0

Views: 1479

Answers (1)

Tim Williams
Tim Williams

Reputation: 166126

Dim c As Range, lnk, nm

xStrBody = "Hi there:" & NRes & "<br>" & emailfrm.Body & "<br>" 

for each c in Sheet17.Range("AZ2:AZ" & Lastrow).Cells
    nm = c.value
    lnk = c.EntireRow.Cells(1, "BA").Value
    
    xStrBody = xStrBody & "<a href=""" & lnk & """>" & nm & "</a><br>"

next c

Upvotes: 1

Related Questions