Sending an email from Excel VBA with a hyperlink that doesn't show the link code
I have an Excel VBA module that sends an email that includes a hyperlink to a network drive location (that may have spaces). I have some code that sort of works but needs a bit of help...
Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) strbody = managername & "," & vbNewLine & vbNewLine & _ "Data has been dumped from the survey controller on project number " & newjob & ". The name of the file is: " & vbNewLine & vbNewLine & _ filefromname & vbNewLine & vbNewLine & _ "and it is located in the following folder:" & vbNewLine & vbNewLine & _ "<a href=""<file:///" & GetFolder & ">"">" & GetFolder & "</a>" & vbNewLine & vbNewLine & _ "Comments:" & vbNewLine & surveynotes MsgBox strbody On Error Resume Next With OutMail .To = manageremail .Subject = "Some survey points have been downloaded on one of your projects" .Body = strbody 'You can add a file like this '.Attachments.Add ("C:\test.txt") .Send 'or use .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing
The email sends no problem, and the extra chevrons in the string help me pick folders that have spaces in them. But when the user gets the email, they see the hyperlink source code in the Outlook email like this: (PS - the link works no problem)
instead of seeing it neatly like this:
If I grab the "strbody" variable and paste it into dreamweaver or some other editor, it looks fine, but when the Outlook email is received, the HTML code for the link shows up. What can I do so that the user doesn't see all the <a href> text that goes with the hyperlink?
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Thank you very much & have a great day!
Kevin