简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM