Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to programmatically add a hyperlink in an Outlook message 1

Status
Not open for further replies.

cardiac

Technical User
Feb 19, 2004
31
GB
Hello,

I've added some VBA to an Excel workbook to allow it to be automatically sent for approval. I use VBA to create an Outlook message informing the approver that they need to approve the new item.

Instead of sending the form as an attachment, I need to send a link to where it is stored but I am having problems adding the hyperlink to the file's location in the outlook message. Here is my code:
Code:
strDesignNotePathname = Sheet3.[DNPath]
Set objMail As New Outlook.MailItem

With objMail
        .To = strApprover
        .Subject = "Design Note for Approval - " & Sheet8.Range("DN_Number")
        .Display
        .BodyFormat = olFormatHTML
        .HTMLBody = "<html><body><p>Please review and action the following <a href=[COLOR=red]strDesignNotePathname[/color]>Design Note</a></p></body></html>"
        '.ReadReceiptRequested = True
        If dteReleaseDate <> #12:00:00 AM# Then
            .FlagStatus = olFlagMarked
            .FlagDueBy = dteReleaseDate
        End If
    End With

The HTML does not recognise the VBA string (obviously) but I don't know how to pass the hyperlink into the body of the message.

Can anyone help me?

Thanks,

David
 
Provided strDesignNotePathname contains a valid URL:
.HTMLBody = "<html><body><p>Please review and action the following <a href=[!]" & [/!]strDesignNotePathname[!] & "[/!]>Design Note</a></p></body></html>"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top