Hello,
I've used the simple code below a lot of times succesfully:
[VBA]Sub SendVBAMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
If OutApp Is Nothing Then
Set OutApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "name@domain.com"
.Subject = "This is the Subject line"
.Body = "Hi there"
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub[/VBA]
When Outlook is opened, the code runs fine.
The fact is that when Outlook is closed, a new instance of it will be created and I get an error at .Send method. Any ideas? In Office 2003 this code worked fine.
*I tried executing it in Windows 7, Office 2010/32 and 64 bits (different computers). I tried late binding it too. I think it is a security issue from Outlook 2010.