Excel VBA Macro: Send Email with Hyperlink (that has Spaces in the File Name)
Excel VBA Macro: Send Email with Hyperlink (that has Spaces in the File Name). In this video, we go over how to ensure that a hyperlink with spaces in the filename does not get cut off after the first space.
Code (KZread doesn't allow brackets; so LT and GT are used for less than and greater than, respectively):
Sub send_hyperlink_with_spaces()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim link As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
link = Replace(ThisWorkbook.Sheets("Sheet1").Cells(1, 1).Text, " ", "%20")
MsgBox link
strbody = "LT BODY style = font-size:14pt; font-family:Arial GT" & _
"Hello Team, LT p GT Please see the link for today: " & _
"LT a href= " & link & "GT here LT / GT LTp GT" & _
"Best regards, LT br GT Greg"
On Error Resume Next
With OutMail
.to = "abc@123.com"
.CC = "me@me.com"
.BBC = ""
.Subject = "Morning Link " & Format(Date, "mm-dd-yyyy")
.display
.HTMLBody = strbody & .HTMLBody
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
#ExcelVBA #ExcelMacro
Пікірлер: 11
amazing! thanks, like 👍👍👍
Hey buddy, Thanks for the fantastic content. Just a quick question on font type/family. Though we selected Arial, draft is coming as Calibri. Can you please help?
Very good video, thank you!
@greggowaffles
Жыл бұрын
Thanks for watching!
Very nice, thanks !
@greggowaffles
Жыл бұрын
No prob! Thanks for watching
@Nick_88888
Жыл бұрын
@@greggowaffles any advice on how to learn all this, what topics to read, html vb ?
@greggowaffles
Жыл бұрын
I would look for code that already exists, and make tweaks and edits, so that you can see how all of the moving parts work together. Also come up with your own vb projects so that you can test yourself and build upon what you know already. Just have fun with it!
Ayeeeeeeee
@greggowaffles
Жыл бұрын
😎😎
I already mentioned how good of video this is. I tried and it worked just great. I just have a question. I tried sending a email to Outlook and the link worked fine. However, sending emails to Gmail o Yahoo the link does not show. Why is that? Thanks so much in advanced.