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.
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 = "" .Body = xEmailBody .Display '.Send End With Set xMailOut = Nothing Set xOutApp = Nothing Application.ScreenUpdating = True End Sub
- 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 = 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.
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.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
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!