Use vba to insert website hyperlink to email body

Leeinsa

Board Regular
Joined
Jul 24, 2009
Messages
96
Hi guys,

This sounded so simple when I thought about doing it, but I cannot find the answer anywhere.

I have a macro in an excel 2007 workbook, i have a macro which takes data from various worksheets within the workbook and contructs emails (outlook 2007) automatically. Everything works great except:-

at the bottom of my message body, i want to add a hyperlink to our website, but it appears on the email as plain text, not a hyperlink. Outlook is set up to send emails as HTML.

The body of the email is constructed using srting variables so the macro code for the email body loos something like this,

dim strBody as string, strWeb as hyperlink

strWeb = "www.mywebsite.com"
strBody = "blah blah blah" & "<br>" & "Regards," & "<br>" & strWeb


Anybody have any idea, how i should format the hyperlink so it shows up on the email as a usable active hyperlink?

Any help much appreciated.
Lee.
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,769
Office Version
365
Platform
Windows
You need to use the HTMLBody property for the message body and set it to the required HTML code for your link etc.

I can't seem to be able to post an example, the board software seems to be parsing the HTML.
 

Leeinsa

Board Regular
Joined
Jul 24, 2009
Messages
96
Hi Norie,

Thanks for the reply, I tried using HTMLBody attribute as shown below but I get a syntax error. Any idea's why? I have tried encapsulating everything in " marks but still no joy.

'With OutMail
' .To = addtemp
' .CC = cctemp
' .BCC = bcctemp
' .Subject = subtemp
' .HTMLBody = Google

' .Display
'End With

Many thanks,
Lee.
 
Last edited:

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,769
Office Version
365
Platform
Windows
Lee

As you can see the board has parsed what you posted and is showing the link not the code.

I can only guess that the syntax error is something to do with quotes.

I think you need quotes around the URL when creating a link in HTML.

I know there is a way to post HTML code but I've just forgotten it.:eek:
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,987
Messages
5,514,631
Members
409,011
Latest member
mccmark

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top