Consulting

Results 1 to 3 of 3

Thread: Attaching hyperlink to Outlook from Excel

  1. #1
    VBAX Newbie
    Joined
    Mar 2006
    Posts
    2
    Location

    Attaching hyperlink to Outlook from Excel

    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?

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi and welcome to VBAX

    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:[VBA]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
    o.Display[/VBA]
    K :-)

  3. #3
    VBAX Newbie
    Joined
    Mar 2006
    Posts
    2
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •