How to copy range from excel and put to outlook

Tur3n

New Member
Joined
Jul 14, 2022
Messages
11
Office Version
  1. 2013
Platform
  1. Windows
Dear All,
currently I have working VBA code which open new email, set subject, recipients etc:

VBA Code:
Sub Send_email()

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strBody = "<FONT SIZE = 3>DHL Express w zalaczeniu. "

With OutMail
    .Display
    .To = "xxx@aaa.com"
    .CC = "xxx@aaa.com"
    .BCC = ""
    .Subject = "Przerzuty - " & Date
    .HTMLBody = strBody & .HTMLBody
    .Display

End With

Set OutMail = Nothing
Set OutApp = Nothing

End Sub

However, I wanna to copy some selection/range from excel and put in the same format but in outlook message.

VBA Code:
 Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy

1660825005532.png


How to do it ? I don't paste it as image but only as editable table from excel.

Thanks,
Adam
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Dears,
can someone help me with above request ?

Shall I explain in more details ?
 
Upvote 0
In case this question is still open and the question is "how do I insert parts od a spreadsheet into an email" then I should suggest using the following Function:
VBA Code:
Function RangePublish(ByVal mySh As String, ByVal PRan As String) As Variant
'Vedi http://www.pc-facile.com/forum/viewtopic.php?f=26&t=101351
'
Dim TmpFile As String, myBDT As String, PubFile
TmpFile = Environ("Temp") & "\myBDT.htm"    'Lavora in Temp
'Crea file html:
With ThisWorkbook.PublishObjects.Add(SourceType:=xlSourceRange, _
    Filename:=TmpFile, _
    Sheet:=mySh, _
    Source:=PRan, _
    HtmlType:=xlHtmlStatic)
    .Publish (True)
End With
'
Set FSO = CreateObject("Scripting.FilesystemObject")
Set PubFile = FSO.OpenTextFile(TmpFile, 1, False)
  RangePublish = PubFile.ReadAll
PubFile.Close
'
End Function
Add it to the same module with the current Sub Send_email, then add in your Sub Send_email the following line:
VBA Code:
    .HTMLBody = strBody & .HTMLBody
    .HTMLBody = HTMLBody & RangePublish("YourSheetName", "YouRange")   'ex: RangePublish("Sheet1", "A2:F20")   '+++ ADDED LINE
    .Display

Try...
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,692
Members
449,330
Latest member
ThatGuyCap

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top