I want to to generate an email through Outlook using Excel VBA.
Then I want to automatically send this email WITHOUT previewing the message/email.
Dim outlookApp As Outlook.Application
Dim outlookMail As Outlook.MailItem
Set outlookApp = New Outlook.Application
Set outlookMail = outlookApp.CreateItem(olMailItem)
With outlookMail
.to = "email_here"
.Subject = "Test"
.Body = "test"
.Send
End With
Set outlookMail = Nothing
Set outlookApp = Nothing
I did turn on the references through the visual basic toolbar to Outlook.
I get all the way to .Send
then the error msg
run-time error '287' Application-define or object-defined error
appears.