conradcliff
Board Regular
- Joined
- Feb 24, 2010
- Messages
- 58
Hey guys, so..I'm trying to figure out how I can send a simple email from excel with he body consisting of certain cell values.
I got some code from rondebruin.nl but when I took the suggestions on how to tweak the message body it breaks the code. here's what I have:
I get:
run-time error '429':
ActiveX component can't create object
it then highlights the "With ThisWorkbook.Sheets("PrintableInvoice")" line of code and when I mouse over that it tells me that < object variable or With block variable not set>
I've looked these things up but can seem to figure it out ...any help would be much appreciated
I got some code from rondebruin.nl but when I took the suggestions on how to tweak the message body it breaks the code. here's what I have:
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)
With ThisWorkbook.Sheets("PrintableInvoice")
strbody = "Hi there" & vbNewLine & vbNewLine & _
.Range("ThisInvoiceEmailInfo")
End With
On Error Resume Next
With OutMail
.To = "cliff@mydomain.com"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = strbody
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
run-time error '429':
ActiveX component can't create object
it then highlights the "With ThisWorkbook.Sheets("PrintableInvoice")" line of code and when I mouse over that it tells me that < object variable or With block variable not set>
I've looked these things up but can seem to figure it out ...any help would be much appreciated