Complex email sent from excel
Posted on 2016-10-18
Can anyone tell me how to edit this code so I can enter a whole selection of cells throughout the email I wish to send. Currently I can only get the address and title and first line to come up, after that nothing I try will work.
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
On Error Resume Next
.To = Cells(ActiveCell.Row, 19)
.CC = ""
.BCC = ""
.Subject = Cells(ActiveCell.Row, 12)
.Body = Cells(ActiveCell.Row, 9)
.Body = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
'SendUsingAccount is new in Office 2007
'Change Item(1)to the account number that you want to use
.SendUsingAccount = OutApp.Session.Accounts.Item(2)