Hello,
I have the below code in Excel that generates emails.
I'd like to add a hyperlink to a website in the middle of the email body but can't work out how?
Does anyone know?
Many thanks
I have the below code in Excel that generates emails.
I'd like to add a hyperlink to a website in the middle of the email body but can't work out how?
Does anyone know?
VBA Code:
Sub SendEmails()
Dim Emails, Subject, FName, SName, Attachment, Body As String
Dim i As Long
Dim OutApp As Object
Dim OutMail As Object
For i = 2 To Rows.Count
If Cells(i, 1).Value = "" Then
Exit Sub
End If
Emails = Cells(i, 1).Value
Subject = Cells(i, 2).Value
FName = Cells(i, 3).Value
SName = Cells(i, 4).Value
Attachment = Cells(i, 5).Value
Emails2 = Cells(i, 8).Value
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With Dest
With OutMail
.SentOnBehalfOfName = "NAME@WORK.co.uk"
.To = Emails
.CC = Emails2
.BCC = ""
.Subject = Subject
.Attachments.Add "C:\UsersMYNAME\Desktop\PIC2.jpg", olByValue, 0
.Attachments.Add "C:\Users\MYNAME\Desktop\PIC1.jpg", olByValue, 0
.BodyFormat = olFormatHTML
.HTMLBody = "<p>Hello " & FName & "," & "</p>" & _
"<p>TEXT PART 1.</p>" & _
"<p></p>" & _
"<p>TEXT PART 2.</p>" & _
"<BODY><IMG src=""cid:PIC1.jpg"" width=485> </BODY>" & _
"<p></p>" & _
"<p> Thanks</p>" & _
"<p></p>" & _
"<BODY><IMG src=""cid:PIC2.jpg"" width=85> </BODY>"
.Attachments.Add Attachment
.Display
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%s"
Application.Wait (Now + TimeValue("0:00:01"))
End With
End With
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Many thanks