Include a hyperlink in the body of an email

Greetings Experts,
I have a maintenance file that includes a "save" button that saves the file and sends two people emails telling them that the file has had an addition.  I have the network address included in the body of the email, but I would like to just click on the address and be able to access the file from the email.  Here is the macro I currently have;


Sub Mail_small_Text_Outlook()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
   
   
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "A new maintenance item has been added to the Maintenance Log. You can view this file at Y:\Common\Facilities Maintenance\Fac Maint Log.xlsm "
*** this is the line that I would like to fix so the file location is a link***



    On Error Resume Next
    With OutMail
        .To = "Rob Cummings <rcummings@grwater.com>; Glen Ray <gray@grwater.com>"
        .CC = ""
        .BCC = ""
        .Subject = "A maintenance item has been added to the Maint Log"
        .Body = strbody
       
        .Send
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
    End With
   
    Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = False
    Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = False

    ActiveWorkbook.Save
       
   
End Sub
graycoLead Maintenance TechnicianAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
Use HTMLBody instead of Body and specify your link with HTML...

Sub Mail_small_Text_Outlook()
     Dim OutApp As Object
     Dim OutMail As Object
     Dim strbody As String
     
     
     Set OutApp = CreateObject("Outlook.Application")
     Set OutMail = OutApp.CreateItem(0)

     strbody = "A new maintenance item has been added to the Maintenance Log. You can view this file at <a href='Y:\Common\Facilities Maintenance\Fac Maint Log.xlsm'>Y:\Common\Facilities Maintenance\Fac Maint Log.xlsm</a> "

     On Error Resume Next
     With OutMail
         .To = "Rob Cummings <rcummings@grwater.com>; Glen Ray <gray@grwater.com>"
         .CC = ""
         .BCC = ""
         .Subject = "A maintenance item has been added to the Maint Log"
         .HTMLBody = strbody
         .Send
     On Error GoTo 0

     Set OutMail = Nothing
     Set OutApp = Nothing
     End With
     
     Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = False
     Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = False

     ActiveWorkbook.Save
     
 End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
a side note...

I think you may consider to remove the line of code: On Error Resume Next and to have a better error handling in your Sub.

if you put the On Error Resume Next in it, the script will keep running, and you will not be notified if that's any errors in sending out the emails.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
do you need any further assistance here?
0
Wayne Taylor (webtubbs)Commented:
Comment answered question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.