Link to home
Start Free TrialLog in
Avatar of grayco
graycoFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
do you need any further assistance here?
Comment answered question