Hi Everyone,
This should be a relitively straight forward question for anyone who know VBA.
I need to amend the following code so that when the email is composed but inserts values from cells in the spreadsheet?
Can anyone tell me how to do this?
The bit of the code I need to amend is shown below. I want to be able to insert the value from B2, B3, B4 for example.
Can someone also tell me how to get the email to send automatically rather than just be drafted for the user to then hit send?
Many thanks,
Jay3
This should be a relitively straight forward question for anyone who know VBA.
I need to amend the following code so that when the email is composed but inserts values from cells in the spreadsheet?
Can anyone tell me how to do this?
Code:
Sub Mail_small_Text_Outlook()
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hi there" & vbNewLine & vbNewLine & _
"Cell A1 is changed" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
On Error Resume Next
With OutMail
.To = "[EMAIL="emailaddresshere@somewher.co.uk"]emailaddresshere@somewher.co.uk[/EMAIL]"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = strbody
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Display 'or use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
The bit of the code I need to amend is shown below. I want to be able to insert the value from B2, B3, B4 for example.
Code:
"Cell A1 is changed" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
Can someone also tell me how to get the email to send automatically rather than just be drafted for the user to then hit send?
Many thanks,
Jay3