ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding a hyperlink to a macro generated e-mail (https://www.excelbanter.com/excel-programming/395697-adding-hyperlink-macro-generated-e-mail.html)

GDCobra

Adding a hyperlink to a macro generated e-mail
 
I am using the following code to send an e-mail from a macro within Excel.
This works but the purpose of the e-mail it to indicate to the recipient a
file which needs to be examined. I would like the filename to appear as a
hyperlink so that when the e-mail is received the name can be clicked on to
open the required file. Can anyone suggest a modification to the code which
would write a hyperlink to the piece of text on the mail?
Any help greatly appreciated.

Public Sub eMailReiterReq()
Dim strbody As String
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String


Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

'Messeage content for e-mail
strbody = "Equipment has failed its check and requires attention." &
vbNewLine & _
"Results Spreadsheet located at:-" & vbNewLine & _
"" & vbNewLine & _
"D:\myfilespathstructure\myimportantfilename.x ls '<<<<<
This is required to be a hyperlink to go direct to the file.


On Error Resume Next
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = strsub
.Body = strbody
.Display
'Application.Wait (Now + TimeValue("0:00:00")) '- Uncomment these
lines to auto send after timer time out.
'Application.SendKeys "%S"
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing



End Sub




All times are GMT +1. The time now is 08:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com