Diving_Dan
Board Regular
- Joined
- Oct 20, 2019
- Messages
- 161
Hi all,
I'm having some issues trying to insert a hyperlink into the body of an email that is generated using VBA from Excel. All of my code works except from the part where I insert the link. After <A HREF = if I type a link manually there instead of trying to insert from a textbox then it works but using the below code the link inserted is me.txtinvoicelink.value instead of the link in that textbox. I hope this makes sense.
Any help is appreciated as always.
Dan
I'm having some issues trying to insert a hyperlink into the body of an email that is generated using VBA from Excel. All of my code works except from the part where I insert the link. After <A HREF = if I type a link manually there instead of trying to insert from a textbox then it works but using the below code the link inserted is me.txtinvoicelink.value instead of the link in that textbox. I hope this makes sense.
Any help is appreciated as always.
Dan
VBA Code:
Private Sub CommandButton1_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim xx As String
xx = "Pack 1"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<font size=3>Hi " + ActiveCell.Offset(, -9).Value + ",<br><br>" & _
"Please find the link " + "<A HREF=me.txtinvoicelink.value>here</A>" + " to your invoice." & _
"<p>As soon as payment is received your order will be shipped within 48 hours and a tracking link provided.</font>"
On Error Resume Next
With OutMail
.SentOnBehalfOfName = "XX"
.display
.To = ActiveCell.Offset(, -3).Value
.CC = ""
.BCC = ""
.Subject = "XX"
.HTMLBody = strbody & .HTMLBody
.display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub