Note: The other languages of the website are Google-translated. Back to English
English English

How to send email from Excel with hyperlink in the email body?

Have you ever tried to send an email with VBA code in Excel? And how to add hyperlinks to the email body text when sending email? This article will help to solve this problem.

Insert hyperlink into email body with VBA code

Insert hyperlink into email body with VBA code

The below VBA code can help to send email from Excel and insert specific hyperlink in the email body. Please do as follows.

1. Launch your workbook, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module, and then copy the below VBA code into the Module editor.

VBA code: Insert hyperlink into email body

Sub EmailHyperlink()
'updated by Extendoffice 20190815
Dim xOtl As Object
Dim xOtlMail As Object
Dim xStrBody As String
    xStrBody = "Hi there:" & "<br>" _
              & "Please click " & "<a href=" & """>Here</a> to open the page" & "<br>" _
              & "Thank you."
    On Error Resume Next
    Set xOtl = CreateObject("Outlook.Application")
    Set xOtlMail = xOtl.CreateItem(olMailItem)
    With xOtlMail
        .To = "Email Address"
        .CC = "Email Address "
        .BCC = " Email Address "
        .Subject = "Subject line"
        .HTMLBody = .HTMLBody & xStrBody
    End With
    Set xOtl = Nothing
    Set xOtlMail = Nothing
End Sub


  • Please change the body content and the hyperlink in the xStrBody line.
  • Replace the “Email Address” in the .To, .CC and .BCC lines with the actual email addresses you will send email to. If you don’t need the CC and BCC lines, just remove them from the whole code, or add a single quote before the lines, such as 'CC =”Email Address”.
  • Replace the “Subject line” in the .Subject line with your email subject own.

3. Press the F5 key to run the code. Then the email is created with specified fields and body with hyperlink listed inside, click the Send button to send it.

Related articles

Automatically send email based on cell value in Excel
Supposing you want to send an email through Outlook to a certain recipient based on a specified cell value in Excel. For example, when the value of cell D7 in a worksheet is greater than 200, then an email is created automatically. This article introduces a VBA method for you to quickly solve this problem.

Send email if button is clicked in Excel
Supposing you need to send email through Outlook by clicking a button in Excel worksheet, how can you do? This article will introduce a VBA method to achieve it in details.

Send email if due date has been met in Excel
Supposing the due date in column C is less than or equal to 7 days (current date is 2017/9/13), then send an email reminder to the specified recipient in column A with specified content in column B. How to achieve it? The method in this article can do you a favor.

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
this code is great, but how to send the current excel sheet in the email?
This comment was minimized by the moderator on the site
you can use "xStrBody" part in other email code, which you are using now. otherwise search "excel to outlook email code".
This comment was minimized by the moderator on the site
you use "xStrBody" part in your existing code, other search Excel to outlook email code online and use "xStrBody" this part.
This comment was minimized by the moderator on the site
please i need help it doesnt work when the link have spaces in itfor ex file path MsgBox "C:\Users\Desktop\fs caché\Fusion fichier\TENDERING.xlsm"
xstrbody = "Request for an approval, <br> You can access to the file from " & "<a href= " & link & ">here</a>"
the link will be in this case : C:\Users\Desktop\fsany idea?
This comment was minimized by the moderator on the site
You can use: xstrbody = "Request for an approval, <br> You can access to the file from " & "<a href="/"" & link & """> here</a >"
This comment was minimized by the moderator on the site
my link isn't clickable and I'm not sure why.

"Please Print <a href="/"http://codes" & Range("JobNumber") & "&ReportId=1"">" & "PhoneCodes</a>"

The link appears but I have to right-click on the email for it to open up. Any suggestions? Also, I don't really know much about VBA. This is something new I'm learning on my own.
This comment was minimized by the moderator on the site
Hi Maryanne,
By default, when you composing an email, hyperlinks are opened by clicking with pressing or holding the Ctrl key.
If you want to open a hyperlink with one click only, please turn off this function as follows.
1. In your Outlook, click File > Options.
2. In the Outlook Options dialog box, click Mail in the left pane, and then click the Editor Options button in the Compose Messages section;
3. In the Editor Options dialog box, click Advanced in the left pane, and then uncheck the Use CTRL + Click to follow hyperlink checkbox. See screenshot:
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations