Sending Table from Excel to Outlook using VBA

Hello,

I would like to send a table in the attached file to Outlook automatically using VBA. How do I do this? I have everything set up in terms of setting up distribution, subject title, and body. I just can't get my macro to copy the table (cells B3-K16) in the attached file to the body of the email. Can someone help me?

Thanks in advance,

GNY

AttachmentSize
Test.xlsm21.8 KB
Vikas Verma's picture

Try this

Hi Dear,

Try this hope it will help you...

Sub Q4_Button1_Click()
Dim olapp As New Outlook.Application
Dim olitem As Outlook.MailItem
Dim shtml As String
Dim rng As Range
Set rng = Sheets("Q4").Range("a1:a6")
shtml = "

"

For i = 1 To 6
shtml = shtml & "

" & "" & "

"
Next
Set olitem = olapp.CreateItem(0)
With olitem
.Display
.Body = "Hi," & vbNewLine & "Please find below Table"
.HTMLBody = shtml
End With

End Sub

" & _
Sheets("Q4").Range("a1") & "
" & _
Sheets("Q4").Range("b1") & "
" & Sheets("Q4").Range("c1") & "
" & Sheets("Q4").Range("a" & i) & "" & _
Sheets("Q4").Range("b" & i) & "
" & Sheets("Q4").Range("c" & i) & "