VBA & Macro Problems

Create an Outlook HTML Email With One Link Using Excel VBA

Maira MehtabMaira Mehtab Nov 27, 2026 868 views

Question details

Create an Outlook email from Excel VBA with ordinary text and a single clickable link.

Create an Outlook HTML Email With One Link Using Excel VBA
Product
Microsoft Excel VBA and Microsoft Outlook
Device & OS
not provided
Scenario
An Excel macro builds an Outlook message using the HTMLBody property.
Observed behavior
The desired message has mostly unformatted text, with one line containing a clickable hyperlink.
Before you start

Open the workbook in desktop Excel and make sure classic Outlook is installed and configured. The macro uses Outlook COM automation, which is not supported by the new Outlook for Windows.

Solution 1Recommended

Use HTMLBody with an anchor tag and line breaks

Use this method to keep most of the email visually plain while adding one clickable link.

HTMLBody can combine ordinary text with HTML tags. The message is still HTML, even though most of its text has no special formatting.

1
Open the VBA editor

In Excel, press Alt+F11, then choose Insert > Module.

2
Add the macro

Paste this code into the module: Sub CreateEmailWithLink() Dim olApp As Object Dim olMail As Object Set olApp = CreateObject("Outlook.Application") Set olMail = olApp.CreateItem(0) With olMail .HTMLBody = "This is a usual text line<br>" & _ "The link: <a href=""http://www.google.com/"">Click Here</a><br>" & _ "Whatever" .Display End With End Sub

3
Customize and run

Replace the example URL, link text, and message lines in the code. Run CreateEmailWithLink from the VBA editor, then review and address the displayed Outlook message.

Use HTMLBody with an anchor tag and line breaks
HTML syntax matters: Use <br> for line breaks and double the quotation marks around the URL inside a VBA string. Assigning HTMLBody replaces the existing message body.
Free Microsoft Office alternative

Work with Excel-compatible spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Office files. It can help you move everyday spreadsheet work from Microsoft Office, but it does not fix Outlook COM automation or guarantee compatibility with this VBA macro.

Open and edit Microsoft Excel XLSX and XLS filesReview spreadsheet data used in email workflowsUse a familiar interface for a smoother transition from Microsoft OfficeWork with documents and presentations in one lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

Can an HTMLBody message contain ordinary text?

Yes. Put ordinary text directly in the HTMLBody string and use tags only where needed, such as <a> for the link and <br> for line breaks.

Why are there doubled quotation marks around the URL?

In a VBA string, doubled quotation marks produce a single quotation mark in the resulting HTML. For example, use href=""https://example.com"" inside the string.

Will this macro send the email automatically?

No. The example uses .Display to open the message for review. Add a recipient and send it from the Outlook window when it is ready.

Can I run this Outlook automation in the new Outlook for Windows?

No. The new Outlook for Windows does not support Outlook COM automation. Use classic Outlook for the CreateObject("Outlook.Application") approach.

Will assigning HTMLBody preserve an existing signature?

Not automatically. Assigning .HTMLBody replaces the current body, so capture and append any existing signature HTML if you need to retain it.