Runtime Error 2147467259 (80004005) (1 Viewer)

lhooker

Registered User.
Local time
Today, 02:53
Joined
Dec 30, 2005
Messages
399
What does the below error mean and do I fix it ?

Runtime Error 2147467259 (80004005)

It fails on ==> Set M = O.CreateItem(olMailItem)

' Remember to add REFERENCE to Microsoft Outlook Object Library

Dim Msg As String

' Msg = "Dear " & Firstname & ",<P> & _
' "Your statement balance as of " & Date & " is " & Format(CreditLimit,"Currency") & "<P>" & _
' "If you have any questions please contact me at (999-9999). "
Msg = "This is the message"

Dim O As Outlook.Application
Dim M As Outlook.MailItem

Set O = New Outlook.Application
Set M = O.CreateItem(olMailItem)

With M
.BodyFormat = olFormatHTML
'.HTMLBody = Msg
' .Body = Txt
' If you use olFormatPlain
.HTMLBody = "This is the message"
.To = "myemaiaddress"
.Subject = "Statement Balance " & Now()
.Display
' .Display to see e-mail screen
' .Send
' .Send to send without e-mail screen
End With

Set M = Nothing
Set O = Nothing
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:53
Joined
Oct 29, 2018
Messages
21,473
It didn't come with any description in the message? Can you post a screenshot?
 

lhooker

Registered User.
Local time
Today, 02:53
Joined
Dec 30, 2005
Messages
399
Here ya
 

Attachments

  • ErrorMessage.jpg
    ErrorMessage.jpg
    57.1 KB · Views: 53

lhooker

Registered User.
Local time
Today, 02:53
Joined
Dec 30, 2005
Messages
399
I also have the below reference box checked in "Tools" . . . References . . .
Microsoft Outlook 16.0 Object Library
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 28, 2001
Messages
27,186
OK, the error is a Permissions error, telling you that Outlook running under your username is not permitted to write to the Outlook "Mail Items" folder, which is an implied folder based on the Component Object Model for "standard" Outlook. I am wondering if your problem is that you are not running in the context of a Trusted Folder.

I would normally consider that error to mean you were set to the wrong mail container but I don't see how that would happen in the context you show us. Unless there was ANOTHER Outlook instance running on the same machine at the same time from a different user. If you aren't on a server, I don't see offhand how you wouldn't have permissions other than the "Trusted Location" issue.
 

isladogs

MVP / VIP
Local time
Today, 07:53
Joined
Jan 14, 2017
Messages
18,221
The same error number can occur in a variety of situations and for widely differing reasons.
For example, this is caused by trying to run command bars code in a subform which works without error in a standalone form:

1704325609693.png


For negative error numbers starting with -2147 . . . focus on the error description rather than the error number
 

lhooker

Registered User.
Local time
Today, 02:53
Joined
Dec 30, 2005
Messages
399
I have no problems receiving or sending emails. So, how can I correct this ?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 28, 2001
Messages
27,186
On further research, that message could ALSO mean that you have something missing from among the list of files you need for the particular operation. Could be a missing reference. Could be a faulty installation. It is one of those "nightmare" errors to decipher because it only happens when something external to Access has the problem. That particular code (80004005) is therefore a "catch-all" for "I tried to use an external facility but it returned an error to me." All I can add is that since you were sending Outlook mail, something might be wrong with your Outlook setup or installation. But that will be a bug-a-boo to track down.

One way you might get some insight is to use the Windows Start button (lower left corner) and type "Event Viewer" into the search box. Then launch Event Viewer. Do this first: Try to send your e-mail. The INSTANT you see the error, note the time in the lower-right corner of the task bar. Then launch Event Viewer and scroll for that time. You would PERHAPS see an Access entry for which the error message tells you that "You don't have permission ...." but you would be looking for an Outlook error that would be more detailed and no more than a couple of seconds before the Access error. The down side of this is that it might be hard to find because there can be several event logs in which to look. And since the error is not fatal (because it starts with 8000 rather than C000), there might not be an event entry anyway.

This is going to be tricky to track down. Like the old Bugs Bunny cartoon, the trick for making Hassenpfeffer is to first catch the rabbit.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:53
Joined
May 7, 2009
Messages
19,243
try configuring Outlook 2016 again.
 

xavier.batlle

New member
Local time
Today, 08:53
Joined
Sep 1, 2023
Messages
21

lhooker

Do you use the old Outlook or the new one?
The code works properly on my computer using the "old version" of Outlook 365, using the new version of Outlook that code won't work never ever!
 
Last edited:

lhooker

Registered User.
Local time
Today, 02:53
Joined
Dec 30, 2005
Messages
399
It appears that when I repaired Outlook (via "File"/"Account Settings"/"Repair") fixed the problem. Thanks for all the help given ! ! !
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 28, 2001
Messages
27,186
Given the symptoms, your chosen solution makes perfect sense. If installation repair fixed the problem, the problem was a somehow faulty installation. Glad we could offer help.
 

Users who are viewing this thread

Top Bottom