VBA outlook - Add email address hyperlink into html body

picklechips

New Member
Joined
Jun 22, 2018
Messages
21
Hi all,

I have a macro that opens an outlook email and attaches documents/puts a blurb in the email body.

I wanted to put a hyperlink in the body of a persons email address, so the receiver should be able to click on the hyperlink and it opens a new email with the "To:" being the email address in the hyperlink.

Below is my .html body code which gets the hyperlink to show up in the email body (blue underline) but when people click on it, nothing happens. Any idea how to make it so a new outlook email opens like when you usually click on an email address hyperlink? .

Thanks in advance!
Pickles


PS. Had to replace the sideways arrows below with square brackets for it to not remove parts of the code.

Code:
.HTMLBody = .HTMLBody & "[p]Salesperson 1 [a href=""salesperson1@hotmail.com""] salesperson1@hotmail.com [/a] T – 647 868 1234 [/p]"
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try putting "mailto:" right before the email address in the href attribute.

Code:
.HTMLBody = .HTMLBody & "[p]Salesperson 1 [a href=""mailto:salesperson1@hotmail.com""] salesperson1@hotmail.com [/a] T – 647 868 1234 [/p]"
 
Upvote 0
Thank you kind sir. Now they can open a new email by holding Ctrl and clicking the hyperlink.

Do you know if theres a way to simly click the hyperlink to open an email instead of having to hold Ctrl and click?


Thanks,
Pickles
 
Upvote 0
Hi never mind, it actually opens an email with one click (no need to hold ctrl).

I think in the email preview it made me have to hold ctrl to open an email.


Thanks again,
Pickles
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,769
Members
448,991
Latest member
Hanakoro

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