troubleshooting Question

Sending an email from Excel VBA with a hyperlink that doesn't show the link code

Avatar of Kevin
KevinFlag for United States of America asked on
OutlookVBAMicrosoft ExcelMicrosoft Office
3 Comments1 Solution96 ViewsLast Modified:
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)

HTML is showing
instead of seeing it neatly like this:

What I want it to look like
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?


Thanks very much!
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros