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.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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.
 
Upvote 0
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:
Upvote 0
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:
 
Upvote 0

Forum statistics

Threads
1,217,254
Messages
6,135,490
Members
449,942
Latest member
Gitad

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top