How to send email with copying and pasting a specified range into email body in Excel?

In many cases, a specified range of contents in Excel worksheet may be useful in your email communication. In this article, we will introduce a method of sending an email with specified range pasting into email body directly in Excel.

Send email with a specified range pasted into email body in Excel
Send email with a specified range pasted into email body with an amazing tool

More tutorials for mailing in Excel...


Send email with a specified range pasted into email body in Excel

The following VBA code can help you to copy a range and paste it into an Outlook email body directly in Excel. Please do as follows.

1. In the worksheet contains the range you need to copy, press the Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. In the opening Microsoft Visual Basic for Applications window, please click Tools > References as below screenshot shown.

3. In the References – VBAProject dialog box, please find and check the Microsoft Outlook Object Library option, and then click the OK button.

4. Click Insert > Module, then copy and paste the below VBA code into the Module window.

VBA code: Send email with a specified range pasted into email body in Excel

Sub Send_Email()
'Updated by Extendoffice 20200119
    Dim xRg As Range
    Dim I, J As Long
    Dim xAddress As String
    Dim xEmailBody As String
    Dim xMailOut As Outlook.MailItem
    Dim xOutApp As Outlook.Application    
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select range you need to paste into email body", "KuTools For Excel", xAddress, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    For I = 1 To xRg.Rows.Count
        For J = 1 To xRg.Columns.Count
            xEmailBody = xEmailBody & "  " & xRg.Cells(I, J).value
        Next
        xEmailBody = xEmailBody & vbNewLine
    Next
    xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine
    With xMailOut
        .Subject = "Test"
        .To = "happy.xuebi@163.com"
        .Body = xEmailBody
        .Display
        '.Send
    End With
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

Notes:

  • 1). Please change the email body in line xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine as you need.
  • 2). Please specify your email recipient and subject (.To = happy.xuebi@163.com and .Subject = "test") lines in the code.

5. Press the F5 key to run the code. In the popping up Kutools for Excel dialog box, please select the range you need to paste in the email body, and then click the OK button. See screenshot:

6. Now an email is created with specified recipient, subject, body and selected Excel range, please click the Send button to send this email. See screenshot shown.

Note: The VBA code is only working when you use Outlook as your email program.


Send email with a specified range pasted into email body with an amazing tool

If you don’t use Outlook and still want to send emails directly in Excel with a specified range data pasted inside, I highly recommend the Send Emails utility of Kutools for Excel for you. With this feature, you just need to configure the outgoing server of an email address, and then send emails in Excel directly via this email address in the future.

Before applying Kutools for Excel, please download and install it firstly.

1. Firstly, you need to prepare a mailing list with needed fields.

  • Tips: The mailing list must contain at least 2 rows, and the first row must be the headers (Supposing you want to send emails to two email addresses in Excel, please type in these two email addresses with header “Email” as the below screenshot shown).
  • Alternatively, you can easily create a mailing list with the Create Mailing List feature.

2. Select the range you will add the data to the email body and press the Ctrl + C keys to copy it.

3. Select the whole mailing list (include headers), click Kutools Plus > Send Emails. See screenshot:

4. Then the Send Emails dialog box pops up.

  • 4.1) Items of selected mailing list are populated in corresponding fields (you can add more fields to the mailing list as you need);
  • 4.2) Click on the email body box, press the Ctrl + V keys to paste the selected range data into it. After that, add other content as you need;
  • 4.3 Uncheck the Send emails via Outlook box;
  • 2.4) Click the Outgoing Server Settings button. See screenshot:

5. Then the Outgoing Server (SMTP) Settings – New Scheme dialog box pops up. Please fill in the email address with its server settings, specify a folder to save all sent mails after checking the Save sent emails to box, and then click the OK button to save the settings.

6. When it returns to the Send Emails dialog box, click the Send button to send the email.

From now on, you can send emails with this feature in Excel directly.

  If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Related articles:

Send email to email addresses specified in cells in Excel
Supposing you have a list of email addresses, and you want to send email message to these email addresses in bulk directly in Excel. How to achieve it? This article will show you methods of sending email to multiple email addresses which specified in cells in Excel.

Insert Outlook signature when sending email in Excel
Supposing you want to send an email directly in Excel, how can you add the default Outlook signature in thie email? This article provides two methods to help you adding Outlook signature when sending email in Excel.

Send email with multiple attachments attached in Excel
This article is talking about sending an email through Outlook with multiple attachments attached in Excel.

Send email if due date has been met in Excel
For example, if 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? This article will provide a VBA method to deal with it in details.

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

More tutorials for mailing in Excel...


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
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.
  • To post as a guest, your comment is unpublished.
    Arul · 6 months ago
    Hi,
    Instead of selecting the range, I want to select multiple pivots in the excel.
    can you please help me.
  • To post as a guest, your comment is unpublished.
    Raman · 9 months ago
    Hi,
    Instead of selecting the range manually, I want to select the range automatically.
    • To post as a guest, your comment is unpublished.
      crystal · 7 months ago
      Hi Raman,
      In the below code, please replace the range "A1:C5" in line Set xRg = Range("A1:C5") with your own range.

      Sub Send_Email()
      Dim xRg As Range
      Dim I, J As Long
      Dim xAddress As String
      Dim xEmailBody As String
      Dim xMailOut As Outlook.MailItem
      Dim xOutApp As Outlook.Application
      On Error Resume Next
      xAddress = ActiveWindow.RangeSelection.Address
      Set xRg = Range("A1:C5")
      If xRg Is Nothing Then Exit Sub
      Application.ScreenUpdating = False
      Set xOutApp = CreateObject("Outlook.Application")
      Set xMailOut = xOutApp.CreateItem(olMailItem)
      For I = 1 To xRg.Rows.Count
      For J = 1 To xRg.Columns.Count
      xEmailBody = xEmailBody & " " & xRg.Cells(I, J).Value
      Next
      xEmailBody = xEmailBody & vbNewLine
      Next
      xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine
      With xMailOut
      .Subject = "Test"
      .To = "happy.xuebi@163.com"
      .Body = xEmailBody
      .Display
      '.Send
      End With
      Set xMailOut = Nothing
      Set xOutApp = Nothing
      Application.ScreenUpdating = True
      End Sub
  • To post as a guest, your comment is unpublished.
    Ther · 11 months ago
    Hi experts, Do we have updates on how the format maintained?
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi Ther,
      Can't figure it out. Sorry for that.
  • To post as a guest, your comment is unpublished.
    Gowtham · 1 years ago
    i am seeing a compile error (User-defined type not defined". Please help me out to overcome this.
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi,
      Please get into the Reference window by clicking Tools > references. Scroll down to find and check the Microsoft Outlook Object Library box and click the OK button to finish the setting.
  • To post as a guest, your comment is unpublished.
    sachin kumr · 1 years ago
    this is pasting as a text. Kindly suggest how to send the table or the same format which is copied from the excel.
  • To post as a guest, your comment is unpublished.
    miguel · 1 years ago
    Code to send automatically after selecting after ok
  • To post as a guest, your comment is unpublished.
    Dhiraj Mahajan · 1 years ago
    Hi
    This code is vary excellent, by using the code i have completed my 90% of my project.
    I have same issue as mentioned by Anirudh that is table formatting. How can i format the table in email.
    Please help me......
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good Day,
      The problem can't be solved yet. Sorry for the inconvenience and thank you for your comment.
      • To post as a guest, your comment is unpublished.
        mahajand09@gmail.com · 1 years ago
        Hi, Is there any update on below.......
        • To post as a guest, your comment is unpublished.
          mahajand09@gmail.com · 1 years ago
          Hi, Also I Wanted code for "Filter by Date".
          I am working on project, on that project I wanted to filter the data by the date, actually we have filter/hide the and last 05 days to current date data and we have highlight all other data.
          Please help me to complete this project.
          Your help is very great-full for me.
  • To post as a guest, your comment is unpublished.
    ghosh · 1 years ago
    This is great. It is working as expected. The only issue is that the format of the table is not maintained in the mail. Can you let me know how do we preserve the format of the table in the mail
  • To post as a guest, your comment is unpublished.
    mfergus · 1 years ago
    This code is great, but I need to execute with a command button rather than pressing F5 in code view. I'd like my employees to be able to fill out some info, then hit the button and have it copy the range of cells they completed and paste into email. I can get code working for the email button and separately for the copy/paste of the range of cells, but can't seem to combine both functions. Please help!!! Thanks!
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Michael,
      You just need to create a button (such as a Button (Form Control)) in your worksheet, then assign the macro to the button.
      • To post as a guest, your comment is unpublished.
        prasana05@gmail.com · 9 months ago
        Hi Crystal, Thank you!
        I had a code created and was wondering how to assign the Command button to the code. Your post helped! and my report works like a charm.

        Thanks again.