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
Attachment | Size |
---|---|
Test.xlsm | 21.8 KB |
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 = "
Sheets("Q4").Range("a1") & "
Sheets("Q4").Range("b1") & "
"
For i = 1 To 6
shtml = shtml & "
Sheets("Q4").Range("b" & i) & "
"
Next
Set olitem = olapp.CreateItem(0)
With olitem
.Display
.Body = "Hi," & vbNewLine & "Please find below Table"
.HTMLBody = shtml
End With
End Sub