Wednesday, 29 January 2020
  0 Replies
  2.5K Visits
0
Votes
Undo
Hello,  Using the VBA below, how do I insert several cell values into the .Subject =Range("G17") ?  I want to add B7, B9, F9, I9 and G13 aswell into the strings in the Subject.
 'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Body content" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = Range("G17")
.CC = ""
.BCC = ""
.Subject = Range("B7")
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
There are no replies made for this post yet.