0

My Questions:

Is there any way to copy a cell range and paste it in the outlook mail body programatically?

I have this code, but it doesn't seem to copy the cell range, but if you type in an individual cell (ex. A4), it's able to copy it.

Sub Email()
   Dim xOutApp As Object
   Dim xOutMail As Object
   Dim xMailBody As String
   Dim szTodayDate As String
   szTodayDate = Format(Date, "mm.dd.yyyy")
   On Error Resume Next
   Set xOutApp = CreateObject("Outlook.Application")
   Set xOutMail = xOutApp.CreateItem(0)
   xMailBody = ActiveSheet.Range("A4:B4").Value
              On Error Resume Next
  With xOutMail
    .To = "tryemail@gmail.com"
    .CC = "tryemail2@gmail.com"
    .BCC = ""
    .Subject = "Schedule for deal pursuit" & " " & szTodayDate
    .Body = xMailBody
    .Display   'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Community
  • 1
  • 1
D.Trump123
  • 37
  • 10
  • 2
    Possible duplicate of [Copying range including formatting when pasting in Outlook email body](https://stackoverflow.com/questions/49163778/copying-range-including-formatting-when-pasting-in-outlook-email-body) – L42 Mar 21 '18 at 06:17

1 Answers1

0

That's the only idea I had .. using a loop to add every cell value to the bodyMail ..

         xMailBody = ""
        ' i represents the columns
        For i = 1 To 2
             xMailBody = xMailBody & " " & ActiveSheet.Cells(4, i).Value
        Next i
LatifaShi
  • 440
  • 1
  • 3
  • 12