Error "The operation failed" occurs only when Outlook is closed.

  • Thread starter Thread starter Dugutigi
  • Start date Start date
D

Dugutigi

I'm using Visual Basic to create and send a message thru Outlook 2003. It
has worked perfectly for over a year at multiple sites, and works whether or
not the user has Outlook open.

However, I have one site where an error occurs only if Outlook is closed.
If Outlook is open, the message is sent just fine. If Outlook is closed, the
user recieves an error message "The operation failed" upon execution of the
following line:

Set objOutlookMailItem = objOutlook.CreateItem(olMailItem)

This is very perplexing because it is only happening at one of over 100
sites. Any help will be greatly appreciated. Thanks.
 
Do you have something loke the following befor you execute that code?

set NS = objOutlook.GetNamespace("MAPI")
NS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
No I don't. I have:

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMailItem = objOutlook.CreateItem(olMailItem)
With objOutlookMailItem
Set objOutlookRecip = .Recipients.Add(strAmName)
objOutlookRecip.Type = olTo
etc, etc, etc
End With

I will try your suggestion tomorrow since the problem site is on the east
coast and they have gone home for the day.

I still don't understand why this is happening only at one of over 100 sites
which in theory have identical equipment and configurations. But I'm happy
to have something to try. Thank you kindly.

I will post a reply tomorrow with the results.
 
Problem solved. The code you provided below was indeed the answer. Thank
you very much for the prompt response.

Daniel Pitt
Seattle, WA
 
Back
Top