I have a code below that will send email to each of my co-workers, I need to add a hyperlink to 'www.mysite.com' in the body of my message but don't know how exactly. Could anyone help? Tried to modify by adding 'var' but as you can see, it's not working.
Code:
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
Dim var
var = " < a href="www.mysite.com">Click this link for updates< /a> "
For r = 1 To Sheets("Email_Address").Range("B1").Value
' Get the email address
Email = Sheets("Email_Address").Cells(r, 1)
' Message subject
Subj = "Sample Message"
' Compose the message
Msg = "Please review: " & vbCrLf
Msg = Msg & var & vbCrLf & vbCrLf
' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A") ' Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
' Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
Next r
End Sub
Last edited: