Hello everyone,
this code is working properly"ish" the only issue when it opens outlook it opens two new emails not one.
then pop up " Reference isn't valid " then a second pop up "click row number #"
this code is working properly"ish" the only issue when it opens outlook it opens two new emails not one.
then pop up " Reference isn't valid " then a second pop up "click row number #"
VBA Code:
Sub addlinks()
Dim lastrow As String
lastrow = Cells(Rows.Count, 1).End(xlDown).Row
For i = 3 To lastrow
If Range("e" & i).Value <> "" Then
ActiveSheet.Hyperlinks.Add Range("Z" & i), Address:="", SubAddress:="CreateEmailWithHTMLBody()", TextToDisplay:="Run Macro"
End If
Next
End Sub
Function CreateEmailWithHTMLBody()
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = "recipient@example.com"
.Subject = "This is the subject"
'Set the HTML body of the email.
.HTMLBody = "<html><body>This is the <b>HTML</b> body of the email.</body></html>"
.Display 'Display the email before sending it.
End With
Set objMail = Nothing
Set objOutlook = Nothing
Exit Function
End Function