MixedUpExcel
Board Regular
- Joined
- Apr 7, 2015
- Messages
- 222
- Office Version
- 365
- Platform
- Windows
Hi all,
I have a list of customers (over 100). I don't want to use a mail merge or database etc. Just simply have the list of e-mail addresses, subject, body of text in a spreadsheet.
The below vba code works perfectly EXCEPT, someone has just asked me to include a hyperlink within the body of the text.
Issue 1. How do you put a hyperlink in the middle of a body of text in a single cell in Excel?
- eg. This is the hyperlink to click here and not the remainder of the text
Only the text in blue is the clickable link, not the rest of the text
Issue 2. If I can find a way to sort out issue 1, would this be transferred to the e-mail as part of the body text in the vba code?
I've thought about referencing another cell to build up the body text cell using formula's but not sure if this would work as I have another hyperlink I also have to include further down the body of text.
Any suggestions would be great. Thanks. Simon
Here's the code which works - it's just the hyperlink issue I'm stuck with.
I have a list of customers (over 100). I don't want to use a mail merge or database etc. Just simply have the list of e-mail addresses, subject, body of text in a spreadsheet.
The below vba code works perfectly EXCEPT, someone has just asked me to include a hyperlink within the body of the text.
Issue 1. How do you put a hyperlink in the middle of a body of text in a single cell in Excel?
- eg. This is the hyperlink to click here and not the remainder of the text
Only the text in blue is the clickable link, not the rest of the text
Issue 2. If I can find a way to sort out issue 1, would this be transferred to the e-mail as part of the body text in the vba code?
I've thought about referencing another cell to build up the body text cell using formula's but not sure if this would work as I have another hyperlink I also have to include further down the body of text.
Any suggestions would be great. Thanks. Simon
Here's the code which works - it's just the hyperlink issue I'm stuck with.
VBA Code:
Sub MailList()
Dim LastRow As String
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = 4 To LastRow ' this is how many rows to check for e-mail addresses
On Error Resume Next
Dim OutApp As Variant
Dim OutMail As Variant
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Cells(i, 2)
.Cc = Cells(i, 3)
.BCC = ""
.Subject = Cells(i, 4)
.Body = Cells(i, 5)
.SentOnBehalfOfName = Cells(4, 1)
On Error Resume Next
On Error GoTo 0
.Save
.Display
.Send '<<<<< if you want to send direct remove "'" to be .send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
On Error Resume Next
Next i
End Sub