Hi all.
Pulling my hair out with this.
I have 2 PC's one running Win XP and one running Win 7
Both have Office 2010
I can run the following code with no problem on the PC running XP, however on the Win 7 PC I get an error, details below
This is a simplified verison of the code for the example.
The error on the Windows 7 PC occurs at the Omail.Send part. I get the following error:
Run-time error '287':
Application-defined or object-defined error
Both systems are running the following references.
Office 14 Object Library
Access 14 Object Library
Outlook 14 Object Library
(plus a few others)
Outlook is open when trying to run the code.
I am clueless and am close to having to resort to a mailmerge which I really dont want to do.
Really appreciate any advice.
Thanks
Alex
Pulling my hair out with this.
I have 2 PC's one running Win XP and one running Win 7
Both have Office 2010
I can run the following code with no problem on the PC running XP, however on the Win 7 PC I get an error, details below
Code:
Sub sendOutlookEmail()
Dim oApp As Outlook.Application
Dim oMail As MailItem
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
oMail.Body = "Body of the email"
oMail.Subject = "Test Subject"
oMail.To = "Someone@somewhere.com"
oMail.Send
End Sub
This is a simplified verison of the code for the example.
The error on the Windows 7 PC occurs at the Omail.Send part. I get the following error:
Run-time error '287':
Application-defined or object-defined error
Both systems are running the following references.
Office 14 Object Library
Access 14 Object Library
Outlook 14 Object Library
(plus a few others)
Outlook is open when trying to run the code.
I am clueless and am close to having to resort to a mailmerge which I really dont want to do.
Really appreciate any advice.
Thanks
Alex