ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hyperlink in body of VBA email (https://www.excelbanter.com/excel-discussion-misc-queries/242982-hyperlink-body-vba-email.html)

Chadersmith

Hyperlink in body of VBA email
 
Hi Guys,

I'm fairly new to VBA so this should be an easy fix. I am trying to include
a network link in the body of an email that is being generated in VBA.

I specifically want to make \\server\file a direct link or hyperlink to a
specific network location. I can't seem to figure out how to do it.

Thanks for your help.

Below is the code:

Sub EmailEE()
'
'Working in Office 2000-2007
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)

strbody = "body of email" & vbNewLine & vbNewLine & _
"\\server\folder" & vbNewLine & vbNewLine & _
"Thank You," & vbNewLine & _
"Me"

On Error Resume Next
With OutMail
..To = "
..CC = "
..BCC = ""
..Subject = "whatever"
..Body = strbody
..Display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

KC

Hyperlink in body of VBA email
 
use
OutMail.htmlbody = strbody
instead of
OutMail.Body=strbody

and include hyperlink in strbody

strbody= "body of email" & vbNewLine & vbNewLine & "<a
href=""\\server\folder""\\server\folder</a" & vbNewLine & vbNewLine &
"Thank You," & vbNewLine & "Me"

-kc
*Click YES if this helps

"Chadersmith" wrote:

Hi Guys,

I'm fairly new to VBA so this should be an easy fix. I am trying to include
a network link in the body of an email that is being generated in VBA.

I specifically want to make \\server\file a direct link or hyperlink to a
specific network location. I can't seem to figure out how to do it.

Thanks for your help.

Below is the code:

Sub EmailEE()
'
'Working in Office 2000-2007
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)

strbody = "body of email" & vbNewLine & vbNewLine & _
"\\server\folder" & vbNewLine & vbNewLine & _
"Thank You," & vbNewLine & _
"Me"

On Error Resume Next
With OutMail
.To = "
.CC = "
.BCC = ""
.Subject = "whatever"
.Body = strbody
.Display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub



All times are GMT +1. The time now is 08:58 PM.

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