View Full Version : Attaching hyperlink to Outlook from Excel

03-08-2006, 01:30 PM
I am trying to create and send an email, using Outlook 2003, from within some Excel 2003 vba code. This part is working fine. However, I want to include a hyperlink to the workbook as part of the body of the email and can't figure out how to do that. Can anyone point me in the right direction?

03-13-2006, 02:12 PM
Hi and welcome to VBAX :hi:

Well it took a while to get a response... hope this helps!
The simplest way would be to set the HTMLBody property of the mailitem (rather than the body) and use html tags for the link.
The code below will give you a quick example to test:Dim o As MailItem
Dim strHTML As String

Set o = CreateItem(olMailItem)
strHTML = "Some text Some text Some text Some text Some text Some text " & _
"<a href=" & """" & "http://www.google.com" & """" & ">This is a link<a/>" & _
" Some text Some text Some text Some text Some text Some text "
o.HTMLBody = strHTML

03-13-2006, 02:28 PM
Thanks Killian. I really appreciate the response. I had just stumbled upon another potential solution when I got your response. The link I am trying to add in my code references a file on our network, so I think I can use

.Body = Trim(cmbRep.Value) & " has a " & Trim([B4].Value) & " quote request for you at " & _
"File://" & QuoteLoc & " for " & cmbQuoteCustName.Value

Adding the File:// at the beginning of the file path automatically converts it to a hyperlink. I'll give both options a shot. Thanks again.