[RESOLVED] Outlook late binding
I'm trying to add a function that will send a warning email when something goes wrong. I have read robDogs example on how to send email using outlook and I'm trying to modify it to use late binding instead.
Code:
Private Sub SendEmail(ByVal workcenter As Integer, ByVal time As Date)
Dim objApp As Object
Dim objEmail As Object
Set objApp = CreateObject("Outlook.Application")
Set objEmail = CreateObject("Outlook.MailItem")
With objEmail
.To = "[email protected]"
.Subject = "Multiple Shop Orders run for line " & workcenter & " at " & time
.body = "TEST"
.send
End With
Set objEmail = Nothing
Set objApp = Nothing
End Sub
However when it gets to the line were I'm creating the MailItem Object the program throws the error "ActiveX component cannot create object". How do I fix this?