Add Hyperlink in Email

B

brittonsm

How do I add a hyperlink to a file in the body of an Email msg?

Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Britton, Steve")
objOutlookRecip.Type = olTo

' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft
Outlook"
.Body = "This is the body of the message." & vbCrLf &
vbCrLf & _
"W:\purprod\public\Ellis\2008 Tracking Tools\PPV POs
Top 10\PPV Report Forward Looking 11-06-08.xls"
.Importance = olImportanceHigh 'High importance

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

.Save
.Send

End With
Set objOutlook = Nothing
End Sub
 
M

Michael Bauer [MVP - Outlook]

This notation should work:

<file:///c:\test%20file.xls>

Spaces must be replaced by '%20'.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 6 Nov 2008 09:54:30 -0800 (PST) schrieb brittonsm:
 
B

brittonsm

Worked perferctly, BUT... It's ugly in the email, how do I clean it
up like an href type of link so that I can say maybe

click this "link" to access the file. and the "link" have the file:///
reference hidden in it?

Thanks....

Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim strDirectory As String
Dim strFileName As String

strDirectory = "W:\purprod\public\Ellis\2008 Tracking Tools
\PPV POs Top 10\"
strFileName = "PPV%20Report%20Forward%20Looking%20" &
Format(Date, "mm-dd-yy") & ".xls"

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Britton, Steve")
objOutlookRecip.Type = olTo

.Subject = "This is an Automation test with Microsoft
Outlook"
.Body = "This is the body of the message." & vbCrLf &
vbCrLf & "<file:///" & strDirectory & strFileName & ">"
End With
Set objOutlook = Nothing
End Sub
 
M

Michael Bauer [MVP - Outlook]

That works only with html formatted e-mails. In html it looks like this:
mail.htmlbody=<a href='d:\test.txt'>file</a>

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 6 Nov 2008 15:58:21 -0800 (PST) schrieb brittonsm:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top