Instead of selecting the range, I want to select multiple pivots in the excel.
can you please help me.
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.
Easily send emails directly in Excel:
The Send Emails utility of Kutools for Excel can help you easily send emails based on specified mailing list fields in Excel. Checking the Use Outlook's signature settings option will help to add Outlook signature to all sending emails. Download Kutools for Excel now! ( 30-day free trail)
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 = "firstname.lastname@example.org" .Body = xEmailBody .Display '.Send End With Set xMailOut = Nothing Set xOutApp = Nothing Application.ScreenUpdating = True End Sub
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.
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.
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.