We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Send email with hyperlink

Medium Priority
Last Modified: 2012-06-21
I am trying to have an email created from Access which has a hyperlink in the body of the message.  The code I have now is working fine and the hyperlink is fine.  What I want to do is change the hyperlink to a display name/word

I am currently using the docmd.sendobject with the following syntax...

DoCmd.SendObject , , acFormatHTML, [EmailAddress], , , "Request pricing for new product", "Dear consumer," & Chr(10) & Chr(10) & "The product you requested can be found on the website:" & Chr(10) & Chr(10) & "http://www.computraksystem.com/componentsdetail.asp?procode=" & Me![ProductDatabaseList]

So... Instead of showing http://www.computraksystem.com/componentsdetail.asp?procode=1 in the body of the email, I would like it to show something like "Click Here"

Watch Question

Leigh PurvisDatabase Developer

Are you using Outlook? (Not express)
Could you perhaps create an email through automation - and use the BodyHTML to create the desired text?


I am using express and outlook.  

How would I do it through automation?
Database Developer
Try something like

On Error Resume Next

    Dim objOutlook As Object
    Dim objItem As Object
    Dim strBody as String

    strBody = "Dear consumer,<br><br>The product you requested can be found on the website:" & _
            "<br><a href=""http://www.computraksystem.com/componentsdetail.asp?procode=" & _
            Me![ProductDatabaseList] & """>Click Here</a>"

    Set objOutlook = CreateObject("Outlook.Application")
    Set objItem = objOutlook.CreateItem(0)
    With objItem
        .To = Me![EmailAddress]
        .Subject = "Request pricing for new product"
        .HTMLBody = strBody
    End With

    Set objItem = Nothing
    Set objOutlook = Nothing

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


I tried putting your script into a command button but it doesn't seem to do anything when I click on it.  Do I have to declare or install something to get this to work?  
Leigh PurvisDatabase Developer

Try commenting out the
On Error Resume Next
line - and see what the error is it gives.


I get a runtime error '-2147024770 (8007007e)'

Automation error
The specifed module could not be found.

The error happens on the:

Set objOutlook = CreateObject("Outlook.Application")
Leigh PurvisDatabase Developer

So you perhaps don't have full blown Outlook installed?
(Or is it not set up?)

Just for testing, I created a blank database, pasted LPurvis' code in a new form, i added a few fields to match your email construct and it worked perfectly. Outlook popped up with the email constructed. I agree with him; I think it's an issue with how Outlook is loaded (or not completely loaded) on your workstation.

I did some more research and found a thread in an Outlook help group (sounds like an AA group for chronic emailers :-). This person solved his/her problem by reinstalling Outlook. It might be a risky proposition, but it worked in this case.


Here's the thread:
Yes one thought. Is this an upgrade from an earlier version of Outlook? I've
seen some similar problems when Outlook is upgraded, especially if it wasn't
uninstalled when the upgrade took place. Registrations are all fouled up and
CreateObject then fails. Most often I've seen it with Outlook 2002 -->
Outlook 2003.

Ken Slovak

"Thatch"  wrote in message

> The error happens right after the CreateObject("Outlook.Application") and
> also right after the GetObject("Outlook.Application"). I have run the
> Detect
> and Repair utility and I have disabled ALL Addin applications in the Addin
> Manager.
> In essence, when I create the Outlook object using CreateObject, I get
> the
> "Cannot create ActiveX component." error.
> The only thing I have not done is uninstall Office (with Outlook with it)
> and re-install Office.

> The problem here is that I have quite a few customers that have reported
> the
> same issue with Outlook 2003. Everything works great if  Outlook is open,
> but
> if Outlook is closed and the CreateObject is used, then the stuff does not
> work.
> In some cases, the customers re-install the whole operating system and
> Office and then the CreateObject works (which is something that I really
> do
> not want to do).

> So, any other thoughts???

 From:  Thatch - view profile
Date:  Tues, Feb 15 2005 6:29 pm  

I've uninstalled office 2003, deleted all and any remaining files
on my system of previous Office installations. Scary somewhat to do it.
However, upon re-install, the createobj now works fine. Also, I didn't lose
any information which is what I was fearing (I have 19 email accounts).

Thanx for the help.


Ok... I will try that but a major problem for me is that not all users use Outlook.  I have a bunch of account who use Outlook Express to send their email.  If anything, I think there are more users on the Express than the full version of Outlook.  Can the code be modified in any way to accomodate Express?  

Is there no simple way to have a hyperlink in Outlook Express have a display name?

I know that hyperlinks can be broken into 4 parts.  The following won't work as a hyperlink:


But if I remove the Click# all is well and Express recognizes it as a hyperlink... Is Express just retarted or do I have to code the entire thing in HTML?  I'd prefer not to since I have it working almost perfectly as it sits but I just want to clean it up so that I don't have to show the full hyperlink.
Leigh PurvisDatabase Developer

I can understand that desire - but not having to show the full hyperlink is achieved using HTML.
And the limited (albeit handy) functionality of SendObject can't do everything.
Leigh PurvisDatabase Developer

"It is assumed that any participant not responding to this request is no longer interested in its final disposition."

Hmm - I never really paid attention to that line before.
My lack of comment generally at moments like this isn't a lack of interest - more a case of laid back acceptance ;-)

Although, that said, in this case I don't have much to say still :-S

No is a valid answer, even if it's not one we want.
There are limitations to everything, each at its own level.  OE limitations are well below those of Outlook.  It's just a fact of life.
I don't blame MS for not making OE all singing and dancing - why should they?  They basically give it away.

Oh - see I did have something to say after all :-)
Most Valuable Expert 2012
Top Expert 2013

I'll post the following recommendation, which I believe effectively addresses the original question in this thread.

LPurvis {http:#16253528}

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.