Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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

Have you ever tried to send 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="/"http://www.extendoffice.com"">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
        .Display
    End With
    Set xOtl = Nothing
    Set xOtlMail = Nothing
End Sub

Notes:

  • 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.


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.
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
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.