Try again in the Outlook VBA editor on that PC to verify that Oultook can be
automated. Use both CreateObject for the Application object, and the
intrinsic Outlook.Application object.
Also check under Help | About | Disabled Items just to make sure that the
VBA Add-In isn't disabled.
These are just guesses, as I was going to finger an anti-virus app as well.
However, if scripting is blocked you will not be able to use CreateObject,
but explicit late-bound references to the Outlook Object Model should work.
If it does, something is blocking scripting.
--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog:
http://blogs.officezealot.com/legault/
"JKro" wrote:
I have some code in an access database module that displays an email to send:
Const olMailItem As Long = 0
Const olFormatPlain As Long = 1
Dim olApp As Object
Dim objMail As Object
Set olApp = CreateObject("Outlook.Application")
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.to = strEmail
.Subject = strSubject
.Body = strMessage
.attachments.Add (strAttachmentLocation)
.Display
End With
Set objMail = Nothing
Set olApp = Nothing
This code works fine on several pcs. However on at least one of my pcs, it
does not. The following line:
Set objMail = olApp.CreateItem(olMailItem)
Produces a run-time error, Operation Failed.
All of the pcs are running Outlook 2003. The versions are slightly
different (successful pc: 11.5608.5606, unsuccessful pc: 11.5608.8107) but I
don't think its the version of outlook because alot of my successfull pcs
have slightly different versions.
I checked the virus scan software and it is not blocking any outlook
scripting.
I've been banging my head against a wall for 4 days now... I can't figure
out why this same code would fail on certain pcs (with no real clues as to
why.)
Any help would be greatly appreciated!